Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transfering data from client to the Server via Bean

 
John Lincoln
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have form, which takes some input from the user and submits to the servelt.

If i have bean associated with form values, how do i set these values in the bean and how do i retrieve them on the server-side ?

I created a bean, mybean



but when i retrieve request.getAttribute("mybeanvalue"); on the server side i get null value.

Do iam missing some thing here

please help

thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Lincoln:
Do iam missing some thing here


I don't know what "do iam" means, but the thing that you are missing is that any code on a JSP page gets executed on the server in order to render the HTML page to send to the browser.

Therefore, your bean, and all the code on the page to set it up, executes before the form is even sent to the browser.

You shouldn't be doing anything on the JSP page to try and capture form input. That's the job of the servlet that you are submitting to. The role of the JSP is just to format the form to send to the browser.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic