Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

using useBean in request scope  RSS feed

 
Sven Anderson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I've been trying over and over to place the data from my inputForm.jsp in request scope and then try to retrieve the data from my process.jsp.
I can't understand why not the request object (emp) is available in my second jsp file. It works fine setting the scope to session, but shouldn't I be able to do this using request too?


inputForm.jsp

<jsp:userBean id="emp" class="Employee" scope="request">
<jsp:setProperty name="emp" property="*" />
</jsp:userBean>

<form method="POST" action="process.jsp>
<input type="text" name="firstName">
<input type="text" name="lastName">

</form>


process.jsp

<c ut value="{$requestScope.emp.firstName}" />
 
Sven Anderson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,

Just found out that this piece of code don't even work when I'm setting the scope="session". Another example I worked on did the session scope but not the request scope.. Even more confused now!!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but shouldn't I be able to do this using request too?


No. Think about it for a minute. You set the scoped variable onto request scope in the rquest that generates inputForm.jsp. That request goes out of scope when the response is sent to the browser. End of the line for the scoped variable.
[ December 14, 2005: Message edited by: Bear Bibeault ]
 
Sven Anderson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

But the request from inputForm.jsp is not sent until I press the submit button which means that process.jsp is receiving that request. For example I can without any problems get the request parameters from the first page. Doesn't this also mean that my "emp" object is in the same Request? In addition I'm having the same problems setting the scope="session". I must be doing something fundamentally wrong here.

Thanks
Erik
 
Sven Anderson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again

I understand you now Bear Bibeault. Took me a little while to realise that I need to put my useBean setProperty on the page handling the request from my form. For example can I forward this request multiple times so that a third or a 4th jsp page display the output in form of <c ut value="${requestScope.firstName}" /> etc.

I've just tried this but I couldn't get it to work (even tried using scope="session")

thanks
Erik
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!