File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Login Security and Display Information Confusion Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Login Security and Display Information Confusion Issue" Watch "Login Security and Display Information Confusion Issue" New topic
Author

Login Security and Display Information Confusion Issue

Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Hi all, I need a help for complete security login code. As I'm Developing an online forum and i need users to login to it also I am not able to understand that in a book i read the home page was displayed in servlet only using out.println() method. but as my web page or the home page is well defined using CSS so how can i check the login information and redirect the user to his home page as I have different home pages for different users. Or can I place any page which will show the Redirecting Please Wait... this message and then redirect to the appropriate page.
please help..!! Many Thanks for any help in advance..!!!
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2

I am not able to understand that in a book i read the home page was displayed in servlet only using out.println() method.

perhaps you are reading any old book.
putting html into servlet is bad way to go use jsp instead.

but as my web page or the home page is well defined using CSS so how can i check the login information and redirect the user to his home page as I have different home pages for different users.

take you username and password values in requestParameter in servlet and check check for username and password.
you can use sendRedirect or to redirect to userarea page and display user information correspond to the username and password.
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Well i'm reading that JDBC, Servlets and JSPs Black Book by Santosh Kumar its a 2010 edition. and in that it is given that he has added the html display using out.println() method. for example out.println("<h1>Hello</h1>"); this line will print Hello in h1 size. Do i need to change my book?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

Unless that is an early example before moving on to more complex subjects, I would suggest so. Emitting HTML in a servlet is not a good practice.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Ok. But I'm sorry am still confused. What need to be done now? and If I want a code that once the user is logged in then until he clicks on logout a session should not be over and it should pop up saying Do You want to resubmit the query Please help me am completely stuck and this is the last phase of my project.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2

Ok. But I'm sorry am still confused. What need to be done now?

What yo have done up to now?

when you checked for login, set the user id to session, and in userarea page you can check that weather session is exist or not, if session is there don't ask for login again.
and for logout, you can just invalidate the session.
session.invalidate();
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Well the designing part is over and now i'll begin with the login thing. In that what i want to check if the user is of first year then he should be redirected to FYBCA home page automatically. How can I do that?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Login Security and Display Information Confusion Issue