Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

j_security_check problem!

843838Mar 20 2007 — edited Mar 24 2007
Hey guys,
I'm trying to create a web application. It consists of a login page( typical username- password screen). Once the user clicks on the log-in button, he/she is redirected to their own personalized domain(something similar to (yahoo/gmail/hotmail).
I'm using form-based authentication, since i want to create my own personalized login & error pages.
in the form tag i have set the action as[b] j_security_check and method as post.
But when i click on the login button i get the error message saying http://localhost:8080/webresource/j_security_check not found.

Here is the code for the[b] login.jsp page:
<form action="j_security_check" method="post">
<FONT SIZE="3" FACE="VERDANA">Company &nbsp;&nbsp;&nbsp; </FONT>
<INPUT TYPE=TEXT NAME="Company" SIZE="20">
<BR><BR><BR>
<FONT SIZE="3" FACE="VERDANA">UserName &nbsp;&nbsp;</FONT>
<INPUT TYPE=TEXT NAME="j_username" SIZE="20">
<BR><BR><BR>
<FONT SIZE="3" FACE="VERDANA">Password &nbsp;&nbsp; </FONT>
<INPUT TYPE=PASSWORD NAME="j_password" SIZE="20">
<BR><BR><BR>
<FONT SIZE="3" FACE="VERDANA">
<INPUT TYPE=SUBMIT VALUE="Log In"> </FONT>
</form>

This is the code for logonError.jsp. This page is displayed when the user enters incorrect username or password. :
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>
Login Error
</title>
</head>
<body>
<c:url var="url" value="http://localhost:8080/sbslogin/sbslogin"/>
<h2>Invalid user name or password.<h2>

<p>Please enter a username or password that is authorized to access this application. Click here to try again</h2>

</body>
</html>

The code given below is for security constraints(role-mapping)
Here is the code for sun-web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD
Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/
software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app>
<context-root>/sbslogin</context-root>
<security-role-mapping>
<role-name>ADMIN</role-name>
<group-name>ADMIN</group-name>
</security-role-mapping>
</sun-web-app>

Here is the code for web.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<display-name>sbs</display-name>
<servlet>
<display-name>sbs</display-name>
<servlet-name>sbs</servlet-name>
<jsp-file>C:/project/sbs.jsp</jsp-file>
</servlet>
<security-constraint>
<display-name>SecurityConstraint</display-name>
<web-resource-collection>
<web-resource-name>WRCollection</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>C:/project/sbs.jsp</form-login-page>
<form-error-page>C:/project/logonError.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>ADMIN</role-name>
</security-role>
</web-app>

Once the user clicks login button he/she is supposed to be directed to their domain, which is a jsp page containing required content(Of course, this is done only after authentication).
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 21 2007
Added on Mar 20 2007
3 comments
497 views