Bookmark Topic Watch Topic
  • New Topic

I keep on getting a new session (using WLS 10). how do I keep the previous session?

 
Jay Menorca
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello good folks

Btw, I posted this in the weblogic thread under "where have my session attribs gone?"

Pls. refer to my code below... why am I always getting a new session with this code? anything wrong with it? It runs ok in tomcat - no new sessions everytime. In WLS, new session every form submit...sigh...what to do ...pls help

-------------------------
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String title = request.getParameter("subject");
String strTimeStr = request.getParameter("starttime");
int startTime = Integer.parseInt(strTimeStr);
String endTimeStr = request.getParameter("endtime");
int endTime = Integer.parseInt(endTimeStr);
String[] days = request.getParameterValues("day");

HttpSession sess = request.getSession(true);
SchoolSchedule sched = (SchoolSchedule) sess.getAttribute("sched");

if (days != null){
for (int i=0;i<days.length;i++){
String dayString = days[i];
int day;
if(dayString.equalsIgnoreCase("SUN")) day = 0;
else if(dayString.equalsIgnoreCase("MON")) day = 1;
else if(dayString.equalsIgnoreCase("TUE")) day = 2;
else if(dayString.equalsIgnoreCase("WED")) day = 3;
else if(dayString.equalsIgnoreCase("THU")) day = 4;
else if(dayString.equalsIgnoreCase("FRI")) day = 5;
else day = 6;

SchoolClass clazz = new SchoolClass(title, startTime,endTime, day);
sched.addClass(clazz);
}
}

request.getSession().setAttribute("sched", sched);
getServletContext().getRequestDispatcher("/Schedule.jsp").forward(request, response);
}
-------------------------

I added a few more lines in my servlet and I've noticed that for the WLS deployment, I ALWAYS get a new session when I click the form submit button. That's why the stuff that should've been save in the session from the previous form submit is missing.

I only have two elements in my webapp, a jsp page and a servlet. The jsp page has 2 sections, one for getting user inputs and the other part for displaying it. The servlet gets the data inputted in the jsp, massages this data and adds it to an attribute in the session object. The proper thing would be for the data to persist in the session attributes - but it's not behaving like this.

appreciate any suggestions
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Jay,

We like there to be only one thread per question.
If you feel you've posted to the wrong forum or if you think that your thread would do better in another one, just ask the moderator of that forum to move it for you. We're always happy to do so.

Having the same question in multiple fora usually ends up wasting the time of the people trying to help you.

Closing this one.
-Ben
 
    Bookmark Topic Watch Topic
  • New Topic