Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5955251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:05:13+00:00 2026-05-22T18:05:13+00:00

Possible Duplicate: JDBC Realm Login Page Hello to all, i would like to create

  • 0

Possible Duplicate:
JDBC Realm Login Page

Hello to all, i would like to create an application login feature which bundled with jdbc realm and with custom login form(Form based authentication login constraint method).

Please provide a link or any help is greatly appreciated.

Please help.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:05:14+00:00Added an answer on May 22, 2026 at 6:05 pm

    What kind of container are you using?jBoss?Tomcat?Derby?
    You also need to make use of persistent storage -> yes DBMS is needed. Which one will it be?MySQL?Sysbase?Oracle PL/SQL?MS SQL?

    Documentation is available here for starters:
    http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#JDBCRealm

    In general you need to have a DB backend, a JDBC-ODBC driver (jar) and a container to do the authentication for you.

    However, I’ll provide you with some guidance and insight to help you in case you are stuck.

    Assuming you are using Tomcat 7.0+ and MySQL 5.5 follow the steps here:
    It may seem tedious at first but it quite simple actually.
    First install MySQL or what other DBMS you want. One of the most critical things here is to name and register a MySQL service that the installer will automatically do it for you*.Try to connect to the database**.
    When you successfully do that change the username(root) and password(“”) of the default DBMS privileged user.
    Create a project schema.
    Create 2 tables in the schema named ‘users’ and ‘rights’.
    The first table(users) must have two columns:username and password.
    The second one(rights) must also have two columns:username and role.
    For starters leave both tables blank.

    Now you have to edit the tomcat-users.xml and server.xml that reside in tomcat’s Catalina (aka home) conf(iguration) directory.
    tomcat-users.xml: This file contains roles that are recognisable by tomcat. So, you will need to add at least one such role such as ‘client’, ‘customer’, ‘unauthenticated’ e.t.c.
    In addition, there is at least one tomcat username and password instance in this file that is used when you launch tomcat manually or as a service or via an IDE. That instance needs to be inserted in the database so you need to add it manually (SQL code) in order for the container to authenticate itself (otherwise you’ll get persistent login failures form the container itself).
    server.xml: Now, assuming your JDBC-ODBC driver is added to your project’s classpath, comment out the UserDatabaseRealm

    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
    resourceName="UserDatabase"/>

    and add something like this inside the LockoutRealm (already exists)

    <Realm className="org.apache.catalina.realm.JDBCRealm"
    connectionURL="jdbc:mysql://localhost:3306/SCHEMA_NAME_IN_DB?user=DB_USER;password=DB_PASS" debug="99" driverName="com.mysql.jdbc.Driver"
    userTable="users" userNameCol="username" userCredCol="password"
    userRoleTable="rights" roleNameCol="role"/>

    (or not if you do not want to have a LockOutRealm -> comment it out as well then and paste the above Realm)

    The SCHEMA_NAME_IN_DB, DB_USER and DB_PASS are values that you have had set when you made the schema and changed the username and password of the DBMS privileged user.
    Now, all you need to do is add the running tomcat’s instance username and password (role:’manager-script’) in the database as well as MySQL privileged user’s (role:custom i.e. ‘client’).
    Add also one or two test users for showcase and associate them with a role you’ve added manually in tomcat-users.xml.

    Finally, you need to edit your project’s web.xml file. There you need to provide these:
    Login Configuration, Security Roles & Security Constraints.
    Login Configuration:Provide a login page and a login error page.
    Security Roles: Add here the security roles that you manually added to users-tomcat.xml file and that a user must have in order to access any page by having logged in.
    Security Constraints:Specify what pages need authenticated access by logged in users.

    Example ( weeeh! )

    <security-constraint>

    <display-name>URLsConstraintMechanism</display-name>
    <web-resource-collection>
    <web-resource-name>clientURL</web-resource-name>
    <description>Required access to specified URL with client permissions </description>
    <url-pattern>/securedURL/index.html</url-pattern>
    <http-method>GET</http-method>
    <http-method>PUT</http-method>
    <http-method>POST</http-method>
    <http-method>DELETE</http-method>
    </web-resource-collection>
    … (more web-resource-collections here)

    <auth-constraint>
    <description>Required privileges to access securely constraint URLs.</description>
    <role-name>client</role-name>
    </auth-constraint>

    </security constraint>

    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/index.html</form-login-page>
    <form-error-page>/index_denied.html</form-error-page>
    </form-login-config>
    </login-config>

    <security-role>
    <description>Required privileges to access securely constraint URLs.</description>
    <role-name>client</role-name>
    </security-role>

    This will be much easier if you use an IDE (especially NetBeans for web.xml).

    Have fun!!! and good luck 😀 🙂 😀

    About * and **:
    There are 2 serious bugs in the installers of MySQL 5.5.
    Check this URLif you need help:

    https://serverfault.com/questions/214435/error-1067-the-process-terminated-unexpectedly-when-trying-to-install-mysql-on

    P.S.:I’ll come back tomorrow to add some hints. For now, I’m going to sleep! xD

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C# driver development? I would like to know if I can do
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: Opening url in new tab while i am doing window.open(), my page
Possible Duplicate: how to delete a file? My application first reads the fields in
Possible Duplicate: How do you like your primary keys? I'm aware of the benefits
Possible Duplicate: When do you use the “this” keyword? Hello, I understand that the
Possible Duplicate: ClassNotFoundException com.mysql.jdbc.Driver I have included the mysql-connector-java-5.1.16-bin.jar into my Eclipse library, this
Possible Duplicate: How to get the insert ID in JDBC? Hi, I'm using JDBC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.