Hi
I have made a web application using
struts 1.1. In this I am using
tomcat container security check for log in. For this I have REALM tag in META-INF/context.xml. Now I am thinking to use JNDI for connection pooling, so that I can avoid to put database userid and password in struts-config.xml (datasource). Before implementing jndi it was working perfectly and security check as well, but now it always decline to verify the login.
Here is my code for the the following files:
context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/InformProject" docBase="InformProject">
<Resource name="jdbc/informDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="singh14" password="informPass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/INFORM?autoReconnect=true"/>
<Realm className="org.apache.catalina.realm.DataSourceRealm" debug="99"
dataSourceName="jdbc/informDB" localDataSource="true"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name"/>
</Context>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>InformProject</display-name>
<!-- /// jndi /// -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/informDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>inform Login</title>
</head>
<body>
<form method="POST" action='<%= response.encodeURL("j_security_check") %>' >
Username: |
<input type="text" name="j_username"> |
Password: |
<input type="password" name="j_password"> |
<input type="submit" value="Login"> |
<input type="reset"> |
</form>
</body>
</html>
Can some one help me why it is not working and what is missing?
Thanks