The moose likes JSP and the fly likes Problem with JSP app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with JSP app " Watch "Problem with JSP app " New topic

Problem with JSP app

Sharon Cowling

Joined: Feb 09, 2002
Posts: 18
I have a major problem, the JSP app has started behaving differently since SSL was applied.
A user fills out a form (jsp1), when they click submit they are taken to a JSP controller page (jsp2) that runs checks for errors and business logic. If any errors are found they are forwarded to an error page (jsp3) stating the error message(s), they can click the back button (javascript window.history.back()) which then goes to jsp1, with their fields still containing their details.
But now with SSL when the user clicks back they are taken to a new instance of the form, which is empty. (The users will not like this!)
I know I need to use the session object to acheive getting the users data back into the form, but I'm not quite sure how to do this, I keep getting null pointer exceptions.
Can someone point me to some documentation or explain it to me? This would be most appreciated.
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
If you're familiar with servlets, you can use the HttpSession object to store your session data as attributes. Same thing happens in a JSP, noting that every JSP page has an implicit reference to current session called session.
Val Pecaoco
Ranch Hand

Joined: Dec 05, 2001
Posts: 156
Hi Sharon,
I would like to recommend that you use Struts, an open source MVC framework from The Jakarta Project. You might be using Model 1 in your JSP app, but believe me it's all worth it if you try out Struts.
Struts has so-called ActionForm objects which are tied to forms (obviously). These are session-based so the form fields' values are retained until the session lasts. What's novel is that, just tell Struts that this form has a corresponding ActionForm object, and Struts will automatically tie that form to the ActionForm object for you. Also, ActionForm objects perform field validation when the form gets POSTed so it is another added convenience.
If you are pressed on time, you can use a session bean to track down values of fields in a form, but basically you're just reinventing the wheel.
Ex Animo Java!
-- Val
[ June 25, 2002: Message edited by: Val Pecaoco ]

"Knowledge is power, but enthusiasm is the key." -- Lavern Barn
Sharon Cowling

Joined: Feb 09, 2002
Posts: 18
Thank you for your comments. Unfortunately this app has been written in JSP with a few java classes attached...I will definetely look into Struts on a future java project.
I agree. Here's the link:
subject: Problem with JSP app
It's not a secret anymore!