• Post Reply Bookmark Topic Watch Topic
  • New Topic

making my bean accesible to 3rd JSP using request scope

 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guys I have a real problem. I have a form where I accept the values and call another JSP which populates the bean with the data like:

<jsp:useBean id="userInfo"
scope="request"
class="com.beans.UserInfoBean">
<jsp:setProperty name="userInfo" property="*"/>
</jsp:useBean>

I then call another JSP where I display the data entered to confirm if user wants to insert into the dbase, from there I call
another JSP where I try to insert it into a Dbase using JSTL tags but I cant access the values in this JSP as it seems that the bean gets reset or something. I am using request scope in all 3 JSPs when i specify the bean. But it seems I can only get the bean's values to be available in the next immediate JSP called to show the user what he entered but not the third JSP where i actually try to insert the data into the DBase. If I use session scope I end up with the same data in the database each time I insert. What do I do??
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arvind Birla:
I have a form where I accept the values and call another JSP which populates the bean with the data
That is a very outdated and frowned upon practice. Modern standards dictate that you should be submitting data to a servlet for processing. JSPs should only be used to construct views.

I then call another JSP

JSPs are not methods that you "call" so the term is not meaningful. How are you transferring to the second JSP? Redirect? Forward? Same with the 3rd JSP. (3rd, JSP?! This is a bit of a mess, isn't it?)

The ideal solution is to refactor the processing to servlets and avoid all this JSP trickery. Failing that, we need to know the details of the resource transitions to determine where the scoped variable is being dropped. A request-scoped variable will be lost whenever a new request is created as a result of a redirect.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!