I have a webapp with form-based authentication. On the login page, I have placed a link to a public registration form. The registration adds a user in the database that is used for authentication.
Now, is is possible to do an automatic login as the new user after the registration is complete, without returning to the login page?
UPDATE
More info, as requested:
DataSource in $CATALINA_BASE/conf/server.xml:
...
<GlobalNamingResources>
...
<Resource auth="Container" type="javax.sql.DataSource" name="jdbc/gporder"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/gporder"
maxActive="100" maxIdle="30" maxWait="10000"
username="xxx" password="yyy"/>
...
</GlobalNamingResources>
...
Resource links and realm in $MYWAR/META-INF/context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/gporder">
<ResourceLink global="jdbc/gporder" name="jdbc/gporder"
type="javax.sql.DataSource"/>
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/gporder" debug="99" localDataSource="true"
digest="MD5" roleNameCol="role" userCredCol="password_hash"
userNameCol="username" userRoleTable="rolemap" userTable="users"/>
</Context>
What else? there is a JSP with the HTML registration form, and a servlet that handles the POST when the form is submitted. They are both too long to be pasted here, but the servlet builds a new user and save it in the database (via hibernate).
After that, a redirect is done on an initial page, which causes tomcat to redirect to the login page instead. So my question is: is there a way to use the username and password entered in the registration form to force a login, and avoid further redirects on the login page?
I would like to avoid relying on tomcat's internal classes.