• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JSP, Beans and Session

 
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem I am facing is that Beans does not get(retrieve) the properties in a new JSP page (not the one in which the properties were originally set.). I am using the Model 2 architecture (MVC pattern). JSP is for View and Beans is the Model, Servlets control.
I have a form which uses a bean to set all the properties. I want to display these proerties in another JSP page. The problem is when I use <jsp:getProperty...>, it does not retrieve the property; it returns 'null'. what could be the problem?
For eg:-
Let,
Bean Name: CustomerBean
JSP Page 1: GetInfo
JSP Page 2: PrintInfo
JSP Page 1: GetInfo:
<%@ page language="java" session="true" %>
<jsp:useBean id="customer" scope="session" class="CustomerBean" />
<jsp:setProperty name="customer" property="*" />
.
.
//some code

JSP Page 2: PrintInfo:
<%@ page language="java" session="true" %>
.
.
Customer Name: <jsp:getProperty name="customer" property="customerName" /> //(returns 'null')
.
.
//some code
I have checked the classpath, session configuration in Tomcat(session timeout basically).....nothing helps.
Any idea?


------------------
-------
Raghav.
 
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the server version whether it is Jsp 1.1 compliant or not. And check out in ur bean and give some testing statements in getters/setters to check whether being called or not.
 
Raghav Sam
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anil,
Yes, Tomcat 3.2.1 is compliant with JSP 1.1.
The bean has been thoroughly tested. All the methods work ! The problem as I said is only with the next page. If I use <jsp:getProperty...> and print the properties in the same page(JSP Page 1) itself, it works perfect. Thats why I have a doubt with the session or Tomcat config.
Does Tomcat 3.2.1 have a known bug/problem while handling JSP, Beans and Session?
I actually tried a roundabout method using servlets (without using Bean), i.e., using request.getParameter()...and directly manipulating the properties. It works !

------------------
-------
Raghav.
[This message has been edited by Raghav Sam (edited April 24, 2001).]
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your second page, did you remember to specify the correct scope for the customer bean? Remember, the default is page scope.
- Peter
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ran into this once when moving Java code out of previously-written (by someone else) JSPs and into JavaBeans and custom tag Java handler classes. It was happening in my case because the developer who had written the JSP had embedded a session.invalidate() call way down in the page inside some other Java code. So, even though the bean property was set on that page, the entire session (including that "session" scope property) was invalidated before the page transferred control to the second page that needed the property.
Short version: Look for a session.invalidate() call in your JSPs.
 
Do not threaten THIS beaver! Not even with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic