Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

session problem using Tomcat 3.3.1  RSS feed

Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..

<head><title>This is the html file</title></head>
<form action="/servlet/SampleServlet" method=GET >
<a href="http://localhost:8080/servlet/SampleServlet" > Click to Servlet </a>
import javax.servlet.*;
import javax.servlet.http.*;
public class SampleServlet extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
HttpSession session = null;
session = req.getSession(true);
session.setAttribute("xSample","This is a sample string");
if (session.getAttribute("xSample") != null){
String sSample = (String) session.getAttribute("xSample");
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
<head><title>Sample JSP [age </title></head>
if (session.getAttribute("xSample")!= null){
String strSample= (String)session.getAttribute("xSample");
out.println("Sample got : "+strSample);
System.out.println("String is null");
The cookies enable attributes in Resin which is not specified in tomcat is
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
**** 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.
Murugan Manickam
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!