It is a bad practice to use scriptlets in JSP . Read this nice SO Q&A : How to avoid Java Code in JSP-Files? on this subject .
Coming back to your problem. You are defining a bean using Standard Action as :
<jsp:useBean id="user" class="de.daniel.docmanager.dto.User" scope="session">
</jsp:useBean>
The useBean
tag will look for an instance of the "de.daniel.docmanager.dto.User" class in the session
. If the instance is not already there, it will create a new instance of "de.daniel.docmanager.dto.User" , and put it in the session
.
You have to retrieve the object from the session
scope :
<%
String name = ((de.daniel.docmanager.dto.User)session
.getAttribute("user")).getName();
System.out.println("name: " + name);
%>
I want to do some additional checks, therefor I tried to access the property within the <% %> section
You can use JSTL or some tag library for that purpose.