aspose file tools*
The moose likes JSP and the fly likes passing input type= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "passing input type="text" from jsp to bean & using that in servlet" Watch "passing input type="text" from jsp to bean & using that in servlet" New topic
Author

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

Ratan Kumar
Ranch Hand

Joined: Jul 19, 2006
Posts: 67
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ratan Kumar
Ranch Hand

Joined: Jul 19, 2006
Posts: 67
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

Joined: Jan 10, 2002
Posts: 61221
    
  66

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing input type="text" from jsp to bean & using that in servlet