Jump to content

[Solved] Tommy server java session variable not working


jimmykd

Recommended Posts

In tommy java server session veriable not working...

Showing this...

 

 

HTTP Status 500 – Internal Server Error

Type Exception Report

 

Message An exception occurred processing JSP page [/updateSyllabus.jsp] at line [106]

 

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

 

Exception

 

org.apache.jasper.JasperException: An exception occurred processing JSP page [/updateSyllabus.jsp] at line [106]

 

103: </th>

104: </tr>

105: <%

106: String email = session.getAttribute("email").toString();

107: Connection Conn = null;

108: PreparedStatement PrepareStat = null;

109: String sid = "";

 

 

Stacktrace:

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:584)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:481)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

javax.servlet.http.HttpServlet.service(HttpServlet.java:742)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Root Cause

 

java.lang.NullPointerException

org.apache.jsp.updateSyllabus_jsp._jspService(updateSyllabus_jsp.java:220)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

javax.servlet.http.HttpServlet.service(HttpServlet.java:742)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

javax.servlet.http.HttpServlet.service(HttpServlet.java:742)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Note The full stack trace of the root cause is available in the server logs.

 

Apache Tomcat/8.5.24

Link to comment
Share on other sites

That's a known issue caused by the limitations of Tomcat running in a shared environment like this. Some have managed to get this working by playing with the sessionCookiePath in context.xml or doing various other things (such as prefixing their war with username_ which is also required if WARs need to find resources packed inside them) but its hit or miss.

 

We also don't have many Java programmers on here, so support for broken code is rather limited.

 

Others have had issues with session-related code too: https://www.helionet.org/index/topic/32294-solved-request-for-war-file-to-be-deployed/?hl=%2Bjava+%2Bsession&do=findComment&comment=145801 (no fix found)

 

https://www.helionet.org/index/topic/31718-i-have-uploaded-my-servlet-war-file-could-you-please-activate-it/?view=findpost&p=143545&hl=%2Bjava+%2Bsession (managed to get it working by messing with sessionCookiePath in his WAR's context.xml file)

Link to comment
Share on other sites

Thanks wolstech, but I think it doesn't works.

 

This is my simple context.xml:

 

<Context sessionCookiePath="/">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>

 

and I have put it under mb.war\WEB-INF

I need to do something else?

 

My JSP code is also simple:

 

I set some vars like this:

   session.setAttribute("USERNAME", userName);

 

And I get this var like this:

   session.getAttribute("USERNAME")

 

It works in my local Tomcat.

(I'm sorry if I made a mistake, but I'm a newbie in JSP)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...