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

how to send databean from JSP page to back?  RSS feed

 
Justin(lijun) wang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this way:
in JSP page:
<input type="hidden" name="results" value="<%=(List)request.getAttribute("results")%>">
in back java code:
results = (List)request.getAttribute("results" );

but it does not work.


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course not.

Remember JSP is a server-side technology whose only purpose is to send HTML to the browser.

As HTML has no knowledge of your server-side List, your page can do nothing to "send it back". What do you see when you do a View Source on the page? That's what HTML gets sent to the browser.

If the List must survive across multiple requests, you can place it in the session for later retrieval*. Or, you could serialize the values into hidden input elements on the page and reconstruct the list on the submission.


* If you use the session, be sure to get rid of the scoped variable when you no longer need it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!