Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to read session attribute in JSP

 
ragi singh
Ranch Hand
Posts: 198
Oracle Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i have a web application wherein i login using an html page and then i am redirected to a servlet MaintainingSessions and the code is as follows:-


and my JSP page is as follows:-


However when i run my application it gives me the error:-
Root cause of ServletException.
weblogic.servlet.jsp.CompilationException: Failed to compile JSP /Second.jsp
Second.jsp:19:3: Illegal token.
<%= session.getAttribute("Naming") %>
^
Second.jsp:19:3: Illegal token.
<%= session.getAttribute("Naming") %>
^

at weblogic.servlet.jsp.JavelinxJSPStub.compilePage(JavelinxJSPStub.java:328)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:237)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:182)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:408)
Truncated. see log file for complete stacktrace
>

Can anyone explain why i am unable to retrieve my session attribute from my session in JSP
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The syntax for XML documents is a bit different. It should be


But you should definitely stay away from scriptlets and use EL instead (and name your attribute "naming" instead of "Naming" to avoid problems):
 
ragi singh
Ranch Hand
Posts: 198
Oracle Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not getting it any ways my jsp is unable to read scriptlet or any other jsp expression
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's because you are not using a common JSP file, but an JSP document. Look at your JSP : it starts with an xml tag, and then uses jsp:root. This is a JSP document notation. You won't be able to use the <% %> notation there. Check this.
 
ragi singh
Ranch Hand
Posts: 198
Oracle Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi christophe ,

i am working in eclipse can you tell me how can i create my jsp so that my scriplets are all valid
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the tutorial I posted above ? If you insist on using the <% %> notation, get rid of the xml notation and use standard JSP instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic