• 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

doGet

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have a servlet called LoginServlet that accepts username and password
and I display this form in the doGet() method, when I submit this form I want doGet() of LoginServlet to be called again so that it can check with database .
But won't the username and password be null this time?
What must I do to prevent it from becoming null the second time I call doGet()?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I'm understanding this right. Wouldn't it be null the first time and not the second time? It sounds to me like the first time, you display the form (and the userid/password are not known yet.)
In general, if you want to remember attributes, you can store them in the session.
 
Lucky Singh
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I do that?
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also pass it back and forth in in the request using request.setAttribute in the servlet and request.getAttribute in the JSP. You'll need the RequestDispatcher object to forward the request back to the JSP though.
One thing I do not understand is the use of the GET in the form which will subsequently call the doGet method of the servlet. Choosing GET as the method in the form will append all of the data to the URL and it will show up in the URL bar of your browser. This doen't seem like something you'd want to do for a login screen. I'd use POST instead.
 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

From then on whereever you want to use these details, like in JSP or any other servlet you can type the following get the details


UserInfo class

Hope this helps
 
Sekhar Kadiyala
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first piece of code you need to write in the logon servle.
In the Logon servlet, you can put the code after the userid/password validation.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic