Can we pass parameters to login.jsp in Tomcat Form-Based authentication

B

Bharath

I have a web-application (WebApp_1) running on Tomcat.
The security is Tomcat Container-managed security --
it is FORM-based. The login page is a servlet,
/servlet/loginHandler

<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/servlet/loginHandler</form-login-page>
<form-error-page>/fail_login.html</form-error-page>
</form-login-config>
</login-config>

Two types of users can access my application.
And depending on that, I want to provide appropriate
login pages say
http://<ipaddress>/englishLogin.jsp and
http://<ipaddress>/spanishLogin.jsp

When I access either of these pages, Tomcat invokes
/servlet/loginHandler.

The question is:
When I am in /servlet/loginHandler servlet, I don't
know which URI was accessed. So, while in the
loginHandler servlet how do I access the information
related to the actual URL sent by the browser
(englishLogin.jsp or spanishLogin.jsp)

I'd appreciate any help in this regard.


P.S. I tried adding custom information in HTTP header
so that I can use that information in loginHandler but
that is not a feasible solution.
 
B

Bharath

You can get the URL or URI from the HttpServletRequest object.

Thanks for your response.

getRequestURL and getRequestURI return the following
respectively when invoked from loginHandler.

http://10.2.14.220:8080/servlet/loginHandler (URL)

/servlet/loginHandler (URI)

But what I want to access is the original URL (of a protected
resource, say spanishLogin.jsp).

It appears that Tomcat has exclusive access to the original
URI in this case and it is not accessible from a program.

Is this correct?
 
R

Robert

Ok so you should just use a hidden input that called language and set
it respectively on the page the user hits. Then on the submit you can
parse it as a request parameter.
<input type="hidden" name="language" value="" />

where value is either "spanish" or "english"

in the servlet just do this

String language = request.getParameter( "language" );

Won't that do it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top