Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing input type="text" from jsp to bean & using that in servlet

 
Ratan Kumar
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a very simple login page.
I am trying to input userID and password on index.jsp , trying to set it in LoginBean.java and print these vales in the LoginServlet.java..but here it get null for these values

I want to know how to use jsp,bean and servlet together.

index.jsp
---------



-----------------------------------------------------------------------------------------

LoginBean.java
--------------



------------------------------------------------------------------------------------------
LoginServlet.java
------------------


Hoping some help on this

Thanks
[ July 23, 2007: Message edited by: Ben Souther ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The setProperty tags are not going to work unless your JSP posts to itself (something that is outdated and shouldn't be done if you're using servlets).

Get rid of them.
Also uncomment the getProperty calls in your servlet.
These are how you should be setting the values.

If you want to see an example that does almost exactly what you're trying to do, see SimpleMVC on my site.
http://simple.souther.us.
 
Ratan Kumar
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
But I want to know how can i use jsp, bean & servlet together this way?

How will the values from jsp set into this bean which can be used later?

i want to avoid using - req.getParameter() in the servlet. I wish to fetch the values from the bean in the servlet and not from request parameters.

Pls help
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ratan Kumar:
But I want to know how can i use jsp, bean & servlet together this way?


You can't. These components are not intended to be used in the manner that you are describing,

How will the values from jsp set into this bean which can be used later?


The values aren't available when the JSP is being executed. So how can they be set into the bean? The bean, in request scope, will be discarded prior to the page even being sent to the browser.

i want to avoid using - req.getParameter() in the servlet.


You can't. That's the way that request parameters are obtained. Why would you want to avoid it?

I wish to fetch the values from the bean in the servlet and not from request parameters.


Not possible.

Beans are intened to send information to a JSP page from its controller, not to send information from a JSP page.
[ July 23, 2007: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic