File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to redirect url to the login page?

 
Moieen Khatri
Ranch Hand
Posts: 144
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an application which has a login page which comes up with the URL:

http://localhost:8080/Analyze

when the user fills the login page and clicks submit.it goes to a page with the URL:

http://localhost:8080/Analyze/analyze

Now if i copy the url:http://localhost:8080/Analyze/analyze and paste in a new browser window I get

HTTP Status 405 - HTTP method GET is not supported by this URL

What can I do to redirect back to the login page:

http://localhost:8080/Analyze if I copy paste http://localhost:8080/Analyze/analyze in a new browser window.

Please advice

Thanks!


 
Prashant Hurria
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Per your previous post (regarding sendRedirect) seems your using sendRedirect here.
Anyways to make this happen what method of the HTTPServlet did you override??
Seems you have overridden the doPost() method.
Is that right???
Try puting the Buisines logic in a new method and call this new method from both doGet() and doPost().
 
sandip sangale
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try it or give Full Information to me

Using Following Way you can redirect your page in servlets


1) sendRedirect("path") method

2) RequestDispather obj = context.getRequestDispatcher
obj.forward(req,res);

Check your Login page name and then pass it as a parameter to these methods
 
Prashant Langade
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you can use session management concept from J2EE.Using sessions,you can invalidate the unwanted request
 
Nandhakumar Soundarrajan
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Moieen,

First of all create a new method with request and response as the parameters and call that method from both doGet and doPost, this will avoid the error
HTTP Status 405 - HTTP method GET is not supported by this URL
.

Next step is, try to use HttpSession, so if the session is null, you can redirect to the login page, else if you want to retain your existing logic check that username from the request is null or not, if null then redirect it to login page.

For redirection, you can use sendRedirect or use the following javascript in the servlet to redirect to your main page or login page.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic