Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Serving the incoming request via URL and via JSP page

trupti nigam
Ranch Hand
Posts: 627
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a small webapp which used to take a URL and get the request params from the URL and process the request.
Now I need to add the login page and also serve the URL like above.

Earlier I just had doGet method which used to handle the incoming request via URL.
But with login page I am trying to handle the request that comes via login.jsp in an action. So my doGet has a call handleRequest() that handles the incoming request based on "action". I pass the action via the JSP page.
But with handleRequest() method, if I try to send the request via URL, the request params are all null and they come in as request path.
Is there a way that I can handle the incoming request through JSP in an action and can also handle the request coming in via URL?

So basically I want to support both methods of accepting the user input.
1. Encode the parameters directly into the URL of a link on a page.
2. Query the user for input with an HTML form.

Is it possible to achieve both using same servlet that serves both?

Bear Bibeault
Author and ninkuma
Posts: 65653
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Back up a bit.

If you are trying to add authentication to your web app, you do not do it by hard-coding the logic into the servlets or JSP.

See servlet authentication for info on how to properly add authentication to a Java web app.
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!