aspose file tools*
The moose likes Servlets and the fly likes Servlet Sessions Coding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Sessions Coding" Watch "Servlet Sessions Coding" New topic
Author

Servlet Sessions Coding

Nithish Yalamanchili
Greenhorn

Joined: Aug 16, 2007
Posts: 24
Hai All

Iam new to Servlets and JSP's. I need an application that accepts username and password from browser and place the user in session, so that the user can be checked for session. Please anyone provide code for this application.

Nithish
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

At JavaRanch, we don't just provide code.
We prefer to help people learn how to code these things themselves.

What have you got so far?
What part has you confused?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Nithish Yalamanchili
Greenhorn

Joined: Aug 16, 2007
Posts: 24


I have done upto here. From here where i have to place session object and track the user.



[BPSouther: Added code tags]
[ August 16, 2007: Message edited by: Ben Souther ]
prakash chandra
Greenhorn

Joined: Aug 14, 2007
Posts: 24
Hi,
You have to use Session Tracking in servlets. Session Tracking can be established using any one of the followings:
1. Cookies
2. URL rewriting and
3. Hidden Form Fields

Please go through above topics you will find your answer.


SCJP 6.0
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Create a session and store the username in the session.

You can see the javadoc for HTTPSession , you will find methods to set attribute in session.Check the javadoc for HTTPServletRequest for methods which will create HTTPSession.


Rahul Bhattacharjee
LinkedIn - Blog
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Tip before getting further : we usually use "equals" to compare strings.


[My Blog]
All roads lead to JavaRanch
 
jQuery in Action, 2nd edition
 
subject: Servlet Sessions Coding