Login Example using Servlet, JSP, MySQL and Hibernate Framework.

In this example we are seeing how to develop Registration and Login application using technologies Servlet, JSP, Hibernate Framework and MySQL Database. This application is developed using eclipse IDE. Using Hibernate Framework developer no need to create table in DB, Hibernate framework will take care about creating table. Just developer need to configure DB schema details like username, password, URL (DB TNS entry) and Driver name in the configuration file, named as hibernate.cfg.xml file. and we need to create mapping file with java entity class to Table name and entity properties names to table column names.
i.e, mapping object oriented data to relational data.

Below find the Test Case and flow of the application.























To run the application below Jar file required in lib folder of the application as per the standards of Java Organization.
Below Jar files are available with Hibernate framework. (for more clarification see the previous post: Click Here)
  • antlr-2.7.7.jar
  • cdi-api-1.1.jar
  • classmate-1.3.0.jar
  • dom4j-1.6.1.jar
  • el-api-2.2.jar
  • geronimo-jta_1.1_spec-1.1.1.jar
  • hibernate-commons-annotations-5.0.1.Final.jar
  • hibernate-core-5.2.4.Final.jar
  • hibernate-jpa-2.1-api-1.0.0.Final.jar
  • jandex-2.0.0.Final.jar
  • javassist-3.20.0-GA.jar
  • javax.inject-1.jar
  • jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar
  • jboss-logging-3.3.0.Final.jar
  • jsr250-api-1.0.jar
Below 2 .jar files are available with Tomcat Server (under %Tomcat_Home%/lib folder)
  • servlet-api.jar
  • jsp-api.jar
Below mysql-connector-java-5.1.37-bin.jar file is available with MySQL instillation (under  %MySQL_initialization_location%\Connector.J 5.1\ folder) or available in maven repository.
  • mysql-connector-java-5.1.37-bin.jar
Note: MySQL mysql-connector-java-X.X.X-bin.jar version file is different from MySQL version to version.
For developing application using eclipse IDE software, create a Dynamic web project and create the project structure like below screen short.



User.java is the DTO object, means this is the Data Transfer Object between the application layers. from Controller layer to Service layer, Service layer to DAO Layer etc....
User.java
Below .xml file is the configuration file between the Hibernate framework and MySQL DB, based on the below configuration hibernate create a Table in MySQL DB.
User.hbm.xml
hibernate.cfg.xml :
It is an .xml file, in which DB connection details like username, password, url and Driver Class name etc... & hibernate properties like Dialect, show_sql and hbm2ddl.auto etc....
hibernate.cfg.xml You know very well every Java web application must have deployment descriptor configuration for application (either .xml or annotation configuration), below is the web.xml file for our application.
web.xml
In above web.xml file configured welcome file as a login.jsp page and Servlet class with urls login, registration. here Servlet class are controllers for this application. see the below two controllers.
LoginController.java
RegistrationController.java
Below are the Service declaration and Implementation Classes
BaseService.java
BaseServiceImpl.java
Below are the Dao Declaration and Implementation Classes
BaseDao.java
BaseDaoImpl.java
Hibernate Utility Class for Application. Using this class creating Hibernate connection and using this connection in Application Dao Implementation class
HibernateUtil.java
login.jsp
userRegistration.jsp
home.jsp
Login Example using Servlet, JSP, MySQL and Hibernate Framework. Login Example using Servlet, JSP, MySQL and Hibernate Framework. Reviewed by Gurugubelli Technologies on January 30, 2017 Rating: 5

43 comments:

  1. Bonjour, tout d'abord je vous remercie pour le code bien détaillée. J'ai testé le code mais lors de run de userRegistration un message d'erreur la ressource n'est pas disponible.
    Merci d'avance

    ReplyDelete
  2. Hi Jon,
    Thanks for your comment, I have updated the web.xml file.

    ReplyDelete
  3. the options such as deny, grant, enable and disable login status in SQL Server. It also explains which options to use when. liteblue usps gov login

    ReplyDelete
  4. tried the exact same code, on submitting getting 404

    ReplyDelete
  5. Hi Akshay
    404 error means, your requisted resource URL is not available. Please share me what URL you have requisting and also provide a log trace.

    ReplyDelete
  6. hi your userRegistration.jsp content same like login.jsp

    ReplyDelete
    Replies
    1. Hey Macix, userRegistration.jsp and login.jsp files have different content. Check once.

      Delete
  7. initialy what is the user name and pass word

    ReplyDelete
    Replies
    1. For accessing application first need a user registration and use the same credentials you have given at the time of registration.

      Delete
  8. HI Team,

    am able to see the login and i don't know the credentials

    ReplyDelete
    Replies
    1. I think don't have a default user for this application, First try to register a user your self and use the same credentials for accessing application :)

      Delete
  9. the userRegistration.jsp is same as login.jsp. please help.

    ReplyDelete
    Replies
    1. Hello Debdutta, both jsp files have different content, please check once

      Delete
  10. also login controller and registration controller are same.

    ReplyDelete
    Replies
    1. Hey Debdutta, Login and Registration controllers have similarity but having different business logic. I think you have missed this logic :)

      Delete
  11. hi, I'm receiving the following error message

    Exception occred while reading user data: Cannot open connection

    ReplyDelete
  12. Gowthaman19 June 2019 at 03:18
    hi, I'm receiving the following error message

    Exception occred while reading user data: Cannot open connection

    ReplyDelete
  13. The article is so appealing. You should read this article before choosing the Hadoop consulting services you want to learn.

    ReplyDelete
  14. i got error "id to load is required for loading".what i do?

    ReplyDelete
    Replies
    1. Same error I get.
      So what should I do?

      Delete
  15. where is struts.xml?
    kindly send me this file.

    ReplyDelete
  16. software testing company in India
    software testing company in Hyderabad
    Thanks for providing such a great blog with us about Login Example using Servlet, JSP, MySQL and Hibernate Framework.
    please keep sharing.

    ReplyDelete
  17. Gerçek bodrum bayan arkadaş ile görüşme gerçekleştirmek için Bodrum bayan arkadaş sayfasına giriş yapabilir, Bodrum bayan arkadaş ilaları inceleyebilirsin: bodrumbebekleri.com

    Bodrum bayan arkadaş ilanlarına göz gezdirmek için hemen bodrum bayan arkadaş sayfasına tıkla birbirinden gerçek bodrum bayan arkadaş profillerini görüntüle: bodrumbebekleri

    Bodrum bayan arkadaş sitesi olan Bodrumbebekleri ile sende hemen bir bodrum bayan arkadaş telefon numarasına ulaşabilirsin. Bodrum bayan arkadaş sayfasına giriş yapmak için tıkla: bodrum

    ReplyDelete
  18. You can order percocet online overnight shipping.These solutions are astonishing manufactured substances that change the working of the central tactile framework. When mishandled, they can provoke veritable repercussions, including enormous organ hurt, the improvement of a substance use issue, and even death in occasions of overabundance.
    Order oxycontin 80mg online
    Order dilaudid 8mg online
    Order Percocet 7-5mg online
    Buy oxycontin 40mg online
    Buy oxycontin 80mg online
    Buy Percocet 10-325mg online

    ReplyDelete
  19. I would like to say more thanks about what you have created here on your blog. It is really very informative and interesting. Do you have any idea about the requirements for Turkey visa. A little bit of change in the requirement of a Turkish visa . Check all the updates in one click and increase the chances of your visa approval.

    ReplyDelete

  20. خدمات نقل الاثاث
    The best furniture moving company in Riyadh and Al-Kharj from the Clean Corner is one of the large companies that are widely displayed, where you can get a group of high-level services significantly with prices outside the competition.شركة نقل اثاث بالرياض
    شركة نقل اثاث بالخرج

    ReplyDelete
  21. I think this is one of the most significant information for me. And i’m glad reading your article. But should remark on some general things
    출장샵
    출장샵
    출장샵
    출장샵
    출장샵
    출장샵
    출장샵

    ReplyDelete
  22. Cheap Accident Lawyer has solved many case. Many accident victims face significant financial challenges in the aftermath of a car accident.
    Accident Lawyer in Cheap Price

    ReplyDelete
  23. When you use collateral to secure a loan, the lender has the right to seize and sell your assets to recoup their money if you fail to pay back the debt.
    Personal loan with best Company

    ReplyDelete
  24. Some of these supplemental coverages are included in the core policy, while others are sold as separate policies. Some insurers also offer usage-based insurance, which calculates your vehicle insurance costs based on your driving habits.
    Motorcycle Insurance
    Business Insurance

    ReplyDelete
  25. As a result, more organizations are making regulatory compliance a top priority in their strategic plans. In fact, according to MetricStream’s State of Regulatory Compliance Report 2021, 64% of respondents intend to increase their focus on regulatory compliance in the next 12 months.
    Best Company for Medical Loan

    ReplyDelete
  26. Effectively managing outside legal services can lead to improved efficiency, effectiveness, and consistency of legal services. In today’s complex environment, lawyers need technology that enables them to handle large amounts of data and collaborate in real time.
    Family law Trust Lawyer without advance fee

    ReplyDelete
  27. With a holistic approach that includes technology, process optimization, and collaboration, lending institutions can enhance their Wedding loan approval workflow and improve their overall customer experience. By leveraging advanced Wedding loan Origination Systems (LOS), lenders can automate data collection, speed up processing times, and streamline operations without increasing staff workloads.
    Wedding loan Online

    ReplyDelete
  28. Property Insurance Provides benefits to employees who suffer work-related injuries or illnesses. It helps cover medical expenses and lost wages, protecting both the employee and the employer from liability.
    Online Property Insurance

    ReplyDelete
  29. This is an area that can cause a lot of confusion and stress for many people, and a knowledgeable attorney can help. An Legal Brutality attorneyexperienced can also provide guidance regarding the best way to divide inherited assets between children.

    ReplyDelete
  30. Full coverage Business Owners insurance, also known as major medical or comprehensive coverage, provides broad coverage of healthcare services. Business Owners Policy Insurance New Jersey Some examples of covered services include doctor visits, hospitalizations and prescription.

    ReplyDelete

Powered by Blogger.