I've try to done a assignment at school. But, I'm facing problem.
j_security_check alway return fail. I've try to google many document. but it couldn't solve this.
Anyone has some idea? And how to redirect new page after login, now i can see i could response only a text.
maybe i wrong at <realm-name>UserDatabase</realm-name>
, but i dont know how to change it.
Thanks for your reading,.
Login.html file:
<form id="login" method="post" action="j_security_check" >
<input name="j_username" type="text" value="123">
<input name="j_password" type="text" value="123">
<input type="submit" value="Login" />
</form>
LoginType.java
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// processRequest(request, response);
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("Success");
} finally {
out.close();
}
}
web.xml file:
<servlet>
<servlet-name>Logintype</servlet-name>
<servlet-class>Logintype</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Logintype</servlet-name>
<url-pattern>/Logintype</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>Vaadin application</web-resource-name>
<url-pattern>/Logintype</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>users</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>UserDatabase</realm-name>
<form-login-config>
<form-login-page>/Login.html</form-login-page>
<form-error-page>/Fail.html</form-error-page>
</form-login-config>
</login-config>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
tomcat-user.xml file:
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="users"/>
<user username="123" password="123" roles="users"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
server.xml
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>