You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ryan <ni...@gmail.com> on 2007/06/01 01:09:37 UTC

adding authentication to unprotected page

Hi All,

I was wondering if any of you had experience with this. I want to add a form
on the homepage of an application that allows the user to quickly log in
(see below) and take them to the protected page. I've never done this before
and unfortunately the form below doesn't seem to work, it basically brings
me back to the original page. Any ideas?

Thanks,
Ryan



      <form method="POST" action='/package/protected/index.html' >
      <table>
        <tr>
          <td>Username</td>
          <td><input type="text" class="text" name="j_username" /></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><input type="password" class="text" name="j_password" /></td>
        </tr>
      </table>
      <p>
        <input type="submit" class="button" value="Login" />
      </p>
      </form>

Re: adding authentication to unprotected page

Posted by Pid <p...@pidster.com>.
Ryan wrote:
> Hi All,
> 
> I was wondering if any of you had experience with this. I want to add a 
> form
> on the homepage of an application that allows the user to quickly log in
> (see below) and take them to the protected page. I've never done this 
> before
> and unfortunately the form below doesn't seem to work, it basically brings
> me back to the original page. Any ideas?
> 
> Thanks,
> Ryan

You're submitting to an incorrect script location.
Tomcat auth, (if configured with as FORM), should be submitted to the 
virtual location:

   action="j_security_check"


p


>      <form method="POST" action='/package/protected/index.html' >
>      <table>
>        <tr>
>          <td>Username</td>
>          <td><input type="text" class="text" name="j_username" /></td>
>        </tr>
>        <tr>
>          <td>Password</td>
>          <td><input type="password" class="text" name="j_password" /></td>
>        </tr>
>      </table>
>      <p>
>        <input type="submit" class="button" value="Login" />
>      </p>
>      </form>
> 


Re: adding authentication to unprotected page

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
You need to read up on Tomcats form based authentication.... I think thats 
what you asking.
Form actually looks like this

<FORM ACTION="j_security_check" METHOD="POST">

<TABLE>

<TR><TD>User name: <INPUT TYPE="TEXT" NAME="j_username">

<TR><TD>Password: <INPUT TYPE="PASSWORD" NAME="j_password">

<TR><TH><INPUT TYPE="SUBMIT" VALUE="Log In">

</TABLE>

</FORM>

but you have to tell tomcat to use it... ie set up all sorts of stuff in the 
Web.xml
Its called Declarative security.

So if some1 tries to access a protected page they get taken to the form... 
log on... and then back to the page.  Your way doesnt work because if you 
have 3 protected pages, which 1 must they go to?

Personally I dont like form authentication....
Another way is to just use standard authentication.... ie the browser will 
prompt the user, and then  present the user with links.

ie the user access the main security page... the browser prompts for 
password... they get in and then just click on one of severl links that 
takes them to other pages.
It sets up in a very similar way in web.xml

Or are you trying to get the user to register... and then redirect them to 
the protected site.
thats different again....

Have fun...



----- Original Message ----- 
From: "Ryan" <ni...@gmail.com>
To: <us...@tomcat.apache.org>
Sent: Friday, June 01, 2007 1:09 AM
Subject: adding authentication to unprotected page


> Hi All,
>
> I was wondering if any of you had experience with this. I want to add a 
> form
> on the homepage of an application that allows the user to quickly log in
> (see below) and take them to the protected page. I've never done this 
> before
> and unfortunately the form below doesn't seem to work, it basically brings
> me back to the original page. Any ideas?
>
> Thanks,
> Ryan
>
>
>
>      <form method="POST" action='/package/protected/index.html' >
>      <table>
>        <tr>
>          <td>Username</td>
>          <td><input type="text" class="text" name="j_username" /></td>
>        </tr>
>        <tr>
>          <td>Password</td>
>          <td><input type="password" class="text" name="j_password" /></td>
>        </tr>
>      </table>
>      <p>
>        <input type="submit" class="button" value="Login" />
>      </p>
>      </form>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org