• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic