| Author |
session problem using Tomcat 3.3.1
|
Murugan Manickam
Greenhorn
Joined: Jun 04, 2002
Posts: 10
|
|
Hi all, I am facing a critical problem for session tracking. The code is working fine using resin. but using tomcat 3.3.1, it is not working. let me explain the scenario. I have a html file which calls the servlet, and after processing, the servlet redirects the response to a jsp file using sendRedirect() method. When i retreive the session value using session.getAttribute("xVar") in the jsp, it gives null. then, i used getServletContext().getRequestDispatcher("url").forward(request,response) in the servlet class instead of sendRedirect(), it gives appropriate value in the jsp.. but, it will not work for other pages(entire session).. from this i have confirmed that, session variable setting is working.. I tested the same code with IE5.5 and Netscape 4.7, it gives the same error. I also compared resin.conf file with server.xml,in resin they used enable cookies and URL-Rewriting. Is there any settings to be done in server.xml to get session variables.. Can anyone please ,help me to resolve this issue.. let me paste the code here.. Thanks in advance.. bye, Murugan <html> <head><title>This is the html file</title></head> <body> <form action="/servlet/SampleServlet" method=GET > <a href="http://localhost:8080/servlet/SampleServlet" > Click to Servlet </a> </form> </body> </html> ---------------- import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class SampleServlet extends HttpServlet{ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{ HttpSession session = null; res.setContentType("text/html"); session = req.getSession(true); session.setAttribute("xSample","This is a sample string"); if (session.getAttribute("xSample") != null){ res.sendRedirect("/NetCAST/Home/NC_Sample.jsp"); } String sSample = (String) session.getAttribute("xSample"); System.out.println(sSample); } } ----- Web.xml ------ <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <servlet> <servlet-name> SampleServlet </servlet-name> <servlet-class> SampleServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name> SampleServlet </servlet-name> <url-pattern> /servlet </url-pattern> </servlet-mapping> </web-app> -------- NC_Sample.jsp ------------ <html> <head><title>Sample JSP [age </title></head> <body> <% if (session.getAttribute("xSample")!= null){ String strSample= (String)session.getAttribute("xSample"); out.println("Sample got : "+strSample); System.out.println(strSample); }else System.out.println("String is null"); %> </html> The cookies enable attributes in Resin which is not specified in tomcat is <session-config> <session-max>4096</session-max> <session-timeout>30</session-timeout> <enable-cookies>true</enable-cookies> <enable-url-rewriting>true</enable-url-rewriting> </session-config>
|
 |
Jessica Sant
Sheriff
Joined: Oct 17, 2001
Posts: 4313
|
|
**** Check out the handy dandy UBB [CODE] tags, they'll preserve the whitespace in your code when you post it to make it easier to read.
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
Try this: http://jakarta.apache.org/tomcat/tomcat-3.3-doc/serverxml.html#SessionId
|
 |
Murugan Manickam
Greenhorn
Joined: Jun 04, 2002
Posts: 10
|
|
Hi, I used the default settings for sessionid in server.xml.. Is there any special settings to be done for session id in server.xml In the tomcat doc, there is no where specified for session id.. Can any one tell me the settings of server.xml for sessionid.. thanks in advance, murugan
|
 |
 |
|
|
subject: session problem using Tomcat 3.3.1
|
|
|