Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC Realm using tomcat and oracle is not working for second time onwords.

 
Nazeer Ahammad
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm trying to execute one simple login authotication program using JDBCRealms. I wrote one program it was asking user name and password when i run first time, next time onwords it was not asking username and password. I restarted tomacat but no use, but if i restart my machine then if i run that application it will ask (Because it is first firm time). i tried using session.invalidate(),session.setMaxAge() and session timeout in dd(deployment discriptor) but i didn't get solution.So please help me how it is storing sessions ? where it is storing sessions? and how can i kill that sessions?

Used softwares:

tomcat 7
JDK 1.6
eclipse ide

used programs and configuration file are below:
---------------------------------------------------------

web.xml
------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>jdbcrealms2</display-name>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>JDBC Realm Example</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>employee</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>

--------------------------------------------
context.xml in meta-inf folder
--------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Realm className="org.apache.catalina.realm.JDBCRealm"
connectionName="root"
connectionPassword="root"
connectionURL="jdbcracle:thin:@blrkec96002d:1521:JDBCRealDemo"
debug="99"
driverName="oracle.jdbc.driver.OracleDriver"
roleNameCol="role_name"
userCredCol="password"
userNameCol="user_name"
userRoleTable="tomcat_users_roles"
userTable="tomcat_users"/>
</Context>

-------------------
index.jsp
-----------------
<!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=ISO-8859-1">
<title>Home page</title>
</head>
<body>
Index page
Invoke Generic Servlet
</body>
</html>



Thanks and Regards,
Nazeer Ahammad.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helpful hint: We have a "Code" button on the message editor. It lays down special text tags that can be used to wrap pre-formatted text such as Java code and XML and make it more readable.

The session information is stored in the TOMCAT_HOME/work directory, I believe. For best results, I like to clean out the work, temp, and logs directory before starting Tomcat. Also, if I am deploying a WAR file, I remove the exploded WAR from the webapps directory, since a newer WAR file will not replace older/obsolete exploded WAR directory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic