• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Integrating Struts, Spring and Hibernate in a web application

 
Ranch Hand
Posts: 33
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to integrate Struts 1.3 with Spring 3.2 and Hibernate 4.0 in a Simple user login application. I want

to use MySQL as the database. I am using Eclipse Mars as the IDE for the development.
I already integrated Struts with Spring, it is working well, but I was unable to integrate Hibernate in the

project, please help.
Table user will be used for the database named users is as follows...

Field              Type            Null    Key   Default
---------------------------------------------------------
username   varchar(30)    yes      no   null
password    varchar(40)    yes      no    null
userid         varchar(4)      no       PRI null

Data stored in that table is as follows...

username     password   userid
------------------------------------
admin           admin123     1


Project structure of the application
------------------------------------------


LoginAction.java
-------------------


BusinessDelegate.java
--------------------------


LoginForm.java
------------------


ApplicationContext.xml
----------------------------


struts-config.xml
-------------------


web.xml
-----------


index.jsp
----------
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login page | Hello World Struts application in Eclipse</title>
</head>
<body>
<h1>Login</h1>
<html:form action="login">

<bean:message key="label.username"/>
<html:text property="userName"></html:text>
<html:errors property="userName" />
<br/>
<bean:message key="label.password"/>
<html:password property="password"></html:password>
<html:errors property="password"/><br/>
<html:submit/>
<html:reset/>

</html:form>
</body>
</html>


welcome.jsp
--------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
   pageEncoding="ISO-8859-1"%>
<!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>Welcome page | Hello World Struts application in Eclipse</title>
</head>
<body>
<%
String message = (String)request.getAttribute("message");
%>
<h1>Welcome <%= message %></h1>

</body>
</html>

MessageResource.properties
----------------------------------
error.username=Username is not entered
error.password=Password is not entered
label.username=Login Detail
label.password=Password
label.welcome=Welcome
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can at all help it, do not use Struts 1.x.  See this article for why.

I was unable to integrate Hibernate in the project


What did you try?  What problems did you have?
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic