A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Servlets
Author
Realm, Eclipse and MySQL
Lenny Peter
Ranch Hand
Joined: Apr 22, 2008
Posts: 52
posted
Nov 17, 2009 13:53:52
0
Can anyone see what is wrong here ...
Login.jsp
<form action="SmileyServlet" method="get"> Username <input name="username" type="text" /> Password <input name="password" type="password" /> <input type="submit" value="Login" /> </form>
SmileyServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("This is the Smiley Servlet."); }
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_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>Y_Realms</display-name> <welcome-file-list> <welcome-file>index.htm</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <description></description> <display-name>SmileyServlet</display-name> <servlet-name>SmileyServlet</servlet-name> <servlet-class>servlet.SmileyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>SmileyServlet</servlet-name> <url-pattern>/SmileyServlet</url-pattern> </servlet-mapping> <security-constraint> <web-resource-collection> <web-resource-name>Requires authentication</web-resource-name> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>student</role-name> </auth-constraint> <user-data-constraint> <!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE --> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> </login-config> <security-role> <description>Student</description> <role-name>student</role-name> </security-role> </web-app>
Server XML
<!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> - <!-- <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> --> <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driverName="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/ida?user=alen;password=alen" userTable="user" userNameCol="username" userCredCol="password" userRoleTable="userrole" roleNameCol="rolename" /> - <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> - <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> - <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
MySql DB ida
Table1: roles: rolename (student)
Table2: user: username (alen), password(esbjerg)
Table3: userrole: username(alen), rolename(student)
Thanks
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56178
13
I like...
posted
Nov 17, 2009 14:13:06
0
Can anyone see what is wrong here
Yes, you didn't tell us what the problem is.
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
Lenny Peter
Ranch Hand
Joined: Apr 22, 2008
Posts: 52
posted
Nov 17, 2009 22:45:58
0
I cannot log in...something is wrong...username or password or codes?
What can I add to my codes to get print out errors in Console?
It should be hidden or not?
<!--
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
-->
<!-- <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> --> <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driverName="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/ida?user=alen;password=alen" userTable="user" userNameCol="username" userCredCol="password" userRoleTable="userrole" roleNameCol="rolename" />
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Realm, Eclipse and MySQL
Similar Threads
Problem with enforcing security in web-app
configuration webapp with authentication
HTTP Status 403 Access to the requested resource has been denied
Unable to access the servlet even on entering username/password set in tomcat-users.xml
Having problem when using web.xml to provide login system to user.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter