This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how to redirect url to the login page?  RSS feed

 
Ranch Hand
Posts: 144
  • 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!


 
Ranch Hand
Posts: 40
  • 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().
 
Greenhorn
Posts: 15
  • 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
 
Ranch Hand
Posts: 73
  • 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
 
Greenhorn
Posts: 23
  • 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.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!