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

How can i send Form data from jsp to servlet using bean  RSS feed

 
Banchan Sangma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the jsp:setProperty action is used to receive the bean info in another jsp page.
but i dont know how to do that in the case of a servlet.
jsp:useBean scope is set to session.
 
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
I'm not sure exactly what you are asking, but a servlet can place an object, including beans, in session scope easily. Is that what you are asking?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Likewise a servlet can get an object from session scope easily too, if that was your question.
 
Banchan Sangma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you see, im entering the form details on a jsp, and i want to use a bean to transfer that data from jsp to a servlet.
in the servlet ill be doing the processing of the data.

but i dont how to use the bean (created in the jsp and used to store the form data) in the servlet.

here's my code

This is the JSP


This is BusRegistration.java


As you can see, i dont know what to do with the Servlet
 
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
Banchan Sangma wrote:you see, im entering the form details on a jsp, and i want to use a bean to transfer that data from jsp to a servlet.

That is not possible. JSP is just a server-side templating engine -- what is sent to the browser is the resulting HTML. Please read this article to understand what JSP is and how it works.

To get the submitted form parameters in the servlet, you'd use the getParameter() method or its related methods.
 
Banchan Sangma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh...

i read that article already..
but then what are beans used for?

i mean, i did find a round-about way to send the bean-object to the servlet, involving another jsp page, but it is as i said, a round-about method.

if you can please guide me towards a good article on beans also.
 
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
Banchan Sangma wrote:
i read that article already..
but then what are beans used for?

For many things, but mostly to carry data from a controller servlet to a JSP.

i mean, i did find a round-about way to send the bean-object to the servlet, involving another jsp page, but it is as i said, a round-about method.

Why? Just use the request parameter methods in the servlet the way that they are intended to be used.

You might want to read this article for a discussion on how to proper structure a Java web application.
 
Banchan Sangma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh.. okay thanks for the help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!