• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:forward invokes doPost when manual link invokes doGet.

 
stephenn davidsonn
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All:
I have a jsp page that has a url that looks like this


Now I want to essentially slide through that page by using jsp:forward instead of the link



Problem is, the link invokes the doGet method of my servlet and the jsp:forward invokes the doPost.

Is it posssible to use jsp:forward and specify doGet somehow?

Any alternatives you can suggest?



 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post you deployment descriptor.

Also questioning why a JSP would forward to a servlet? That's rather topsy-turvy.
 
stephenn davidsonn
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


So I have s menu page that looks like this:



Based on the selection, I invoke the approprate controller to do the directing to appropriate .jsp page.

I would like to now go to one page, always. say, the page where I would be taken to if I chose Administrator Subscription Maintenance.

It would be easy enough, if I wanted to keep the link on the page, but I don't. I want to jsp:forward to the Administrator Subscription Maintenance list automatically when this jsp page is invoked by the controller.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still not understanding why would you be using a JSP for dispatching? Use a servlet. A JSP is meant for creating a view, not control.
 
stephenn davidsonn
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me try again, broadening a bit, and a bit more detail about what I have and what I want to accomplish.

I have a login page where I get userid and password and post to my UserController. Here is the login page



As you can see, I am posting the values collected to my servlet, UserController.

The UserController looks like this...


I basically set some session attributes here, then dispatch to a menu. The menu is as follows:



I click on the link and the doGet in the subscription controller dispatches me to a jsp page with a list of subscriptions.

So I think I am letting the servlets do the dispatching.

So this all works nicely, and I can login, get to the menu page (with only one choice therein) and click on the one link to get to my list of subscriptions.

But now, my customer wants to bypass the login page. They want me to simply take the %USERNAME% and not make the user type in their id again.

So I am trying to find the simplest way to meet their needs without rewriting everything. That is why I was looking at jsp:forward from the login menu. Rather than have the user enter
a userid and password, I will now get the %USERNAME% from the user's system variable, and will get rid of the password field. And here is where i circle around to the jsp:forward question I had. As things are now, when the customer enters their userid and password, and presses the submit button, the doPost method of the UserController is invoked. When I try to use jsp:forward, to forward from the login page to the UserController (So it can continue dispatching), the doGet of the UserController is invoked instead of doPost. So my question remains, is it possible to choose which method is invoked in a servlet when forwarding to it via jsp:forward?? Maybe I have it all wrong and I should not bring the controller into the picture this way. If not, what is the alternative to using a form and a submit button when what I want to do is to submit silently, with no user intervention?



 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Being it Monday morning, I still may be dense.

So you are trying to to eliminate logging in and just using some readily available environmental information to identify the user? Correct, so far?

If so, why is there a login page to being with? If you aren't going to ask the user for his or her password, why is there even a need to show a page that says "Here's what you are going to log in as, you don't have a choice."?

Guess I'm still not understanding the scenario as it doesn't seem to make much sense. I just may need more coffee, but it sounds like you are trying to take an authenticated system, turn it into an un-authenticated systems, but still leaving a lot of the authentication mechanism in place, and tripping over it.
 
stephenn davidsonn
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right, of course. When I stepped back and thought about it, all I needed to do was collect the user's id, which is used elsewhere, and which I could get from USERNAME variable, and eliminate the physical login page. Amazing what a cup of coffee and a good night's sleep can do for re-work efforts.

:-

Thanks for your contributions.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's really really easy to miss the forest for the trees when you are being chased through the forest by wolves.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And those wolves often have the titles "Project Manager" and "Business Analyst".
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We all know who the wolves are in our own realities.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!