aspose file tools*
The moose likes Servlets and the fly likes MVC: Controller Servlet forwarding without login Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "MVC: Controller Servlet forwarding without login" Watch "MVC: Controller Servlet forwarding without login" New topic
Author

MVC: Controller Servlet forwarding without login

Michael Knaus
Greenhorn

Joined: Dec 03, 2008
Posts: 4
Hello everybody,

How can I deny a Servlet forwarding if this component should be protected by a login form? I mean, I have a jsp which is denied in the web.xml. If I call the jsp by link, the login form will be displayed - that works. However, if I call the jsp by my Controller Servlet, I get the jsp without any login-form...

Does anyone has a solution?

My web.xml:



My Controller-Servlet:


[ December 03, 2008: Message edited by: Michael Knaus ]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

Put "else" part in the Controller servlet and have a target(different page) there to be forwarded if the choice is not equal to 'profil'. Is this solve your problem?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Michael Knaus
Greenhorn

Joined: Dec 03, 2008
Posts: 4
The default target is already index.jsp. So, target = "myprofil.jsp"; would be just set if the choice is "profil". I don't want to check the user in my Servlet by request.isUserInRole("user") to forward. I'm just looking for a declartive way in the web.xml.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

so, where you are setting the value for choice?

Michael Knaus
Greenhorn

Joined: Dec 03, 2008
Posts: 4
in my index.jsp:



or another way per post button:



edit, and in my servlet per:


[ December 03, 2008: Message edited by: Michael Knaus ]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Michael Knaus:
in my index.jsp:




it will work


or another way per post button:



it wont work ... here you are not passing the value for choice. use hidden field
Michael Knaus
Greenhorn

Joined: Dec 03, 2008
Posts: 4
both examples will put me through to the myprofil.jsp! But without any login-form. In this case:

<a href="adressadmin/myprofil">profil</a><br />

I will get the login-form. But thats not what I want :/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MVC: Controller Servlet forwarding without login