Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using session pages with a bean: problems  RSS feed

 
Eric Ladner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy.
I've got a problem I've been wrestling with for a week and haven't found an answer yet.
I have a JSP page, call it foo.jsp, that requires a parameter for proper operation. So, what it does is if the parameter in the bean isn't set, it shows one section of html which is a form to set that parameter with itself as the submit="". Here's a summary:
<%@page contentType="text/html; charset=iso-8859-1" language="java"%>
<html>
<head>
<jsp:useBean id="fooBean" class="fooBean" scope="session"/>
<jsp:setProperty name="fooBean" property="*"/>
<% if (fooBean.getRequestType()) == null) { %>
<form NAME="form" ACTION="foo.jsp" METHOD="POST">
Select an action type, then Next.   
<select NAME="requestType">
<option VALUE=""> </option>
<option VALUE="A">Add</option>
<option VALUE="C">Change</option>
<option VALUE="D">Delete</option>
</select>
<input TYPE="submit" VALUE="Next >>" NAME="Submit1">
</form>
<% } else { %>
<P>Request type is <%= fooBean.getRequestType() %>
<% } %>
The problem is this:
On the first submit, the bean is empty (naturally).
I can pick a value and submit.
On the next page (supposedly the same JSP page with the value now set in the bean) foobean.requestType is still null.
Any thoughts?
Thanks,
Eric

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is going to sound weird, but you may get better results if you put the bean in a package and instead of:
<jsp:useBean id="fooBean" class="fooBean" scope="session"/>
import the package in the <%@page tag and specify the complete path in the useBean tag:
<jsp:useBean id="fooBean" class="mypackage.fooBean"
scope="session"/>
Bill
 
Eric Ladner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well.. it sort of is fully specified. I simplified the example a bit for the web. It is not listed in the import statement, however. The bean is located in the WEB-INF/classes folder under the Tomcat tree, so I thought it was imported implicitly by Tomcat.
Eric
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!