File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Processing a login page not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Processing a login page not working" Watch "Processing a login page not working" New topic
Author

Processing a login page not working

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1064
I have a very simple login page that's not working as expected.

The idea is that if a user tries to access "premium content", he'll be redirected back to a login page. Currently, this page is just testing and not using any DB lookups:

Here's the login page code in the JSP:

This code "works" in that it does get the user name password and does the sendRedirect to index.jsp.

------

Then, back in index.jsp where the user got redirected after logging in, he should now be able to go to the premium content page, which has (test) verification code like this:


--------------------

The problem is that the code is always going back to the login page from the premium content page: the "loggedIn" session variable is not found.

These pages are separate JSP pages under a Tomcat Webapp.

What am I missing here?

Thanks in advance for any suggestions.

- Mike


[BPSouther: Added code tags]
[ March 31, 2008: Message edited by: Ben Souther ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The first thing I would do, if I were debugging this, is use a System.out.print statement to print the value of your "loggedIn" session attribute.


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

Joined: Mar 20, 2008
Posts: 14
In the "response.sendRedirect('./index.jsp');",you need add two point like this "response.sendRedirect('../index.jsp');"
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344


Originally posted by Mike London:
The problem is that the code is always going back to the login page from the premium content page: the "loggedIn" session variable is not found


It seems the session variable 'loggedIn' was not set in your previous page. I also would go with Ben's suggestion. Try doing it. :thumb:


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1064
Thanks all for all the replies!

The problem turned out to be a firewall issue related to "browser privacy". This issue only happens under certain circumstances.

Just found this a few minutes ago.

Thanks to all for the terrific replies and suggestions!!!



Mike
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

That's great Mike. Looks strange and i wonder how come it prevented this

Anyways thank you for posting back the resolution!

Cheers :thumb:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Processing a login page not working