Posts

Composite Primary Keys Using Embeddable In Hibernate | Code Factory

Image
Download code and jars :  Link. File : UserId.java package com.codeFactory.bean; import java.io.Serializable; import javax.persistence.Embeddable; @Embeddable public class UserId implements Serializable {  String firstName;  String lastName;  public String getFirstName() {   return firstName;  }  public void setFirstName(String firstName) {   this.firstName = firstName;  }  public String getLastName() {   return lastName;  }  public void setLastName(String lastName) {   this.lastName = lastName;  } } File : User.java package com.codeFactory.bean; import javax.persistence.AttributeOverride; import javax.persistence.Column; import javax.persistence.EmbeddedId; import javax.persistence.Entity; @Entity public class User {  @EmbeddedId  @AttributeOverride(name = "firstName", column = @Column(name = "fid_firstnam...

Composite Primary Keys In Hibernate | Code Factory

Image
Download code and jars :  Link. File : ProjectId.java package com.codeFactory.bean; import java.io.Serializable; public class ProjectId implements Serializable{ int departmentId; int projectId; public int getDepartmentId() { return departmentId; } public void setDepartmentId(int departmentId) { this.departmentId = departmentId; } public int getProjectId() { return projectId; } public void setProjectId(int projectId) { this.projectId = projectId; } } File : Project.java package com.codeFactory.bean; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; @Entity @IdClass(ProjectId.class) public class Project { @Id int departmentId; @Id int projectId; public int getDepartmentId() { return departmentId; } public void setDepartmentId(int departmentId) { this.departmentId = departmentId; } public int getProjectId() { return...

Uploading Multiple Files Using jsp servlet | Code Factory

Image
Download code and jars :  Link. File : index.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>Upload page</title> </head> <body> <form action="UploadServlet" method="post" enctype="multipart/form-data" name="form1" id="form1"> <center> <table border="1"> <tr> <td align="center"><b>Multiple image upload</b></td> </tr> <tr> <td> Specify file : <input name="file" type="file" id="file" mul...

Struts2 Hibernate Example With XML

Image
Download code and jars :  Link. File : index.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>Insert title here</title> </head> <body> <center> <br> <br> <form action="insertData" method="post"> First Name : <input type="text" name="firstName"> <br> <br> Last Name : <input type="text" name="lastName"> <br> <br> <input type="submit" value="Submit"> </form> </center> </body> </html> ...

Struts2 actionError and actionMessage.

Image
Download code and jars :  Link. File : index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!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>Index page</title> </head> <body> <center> <s:if test="hasActionErrors()"> <div> <span style="text-align: center; color: red; font-size: 17px;"><s:actionerror /></span> </div> </s:if> <s:if test="hasActionMessages()"> <div> <span style="text-align: center; color: green; font-size: 17px;"><s:acti...

Upload Profile Picture or File using JSP, Struts2 | Code Factory

Image
Download code and jars :  Link. File : temp.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="Refresh" CONTENT="0;URL=index.action"> <title>Insert title here</title> </head> <body> </body> </html> File : index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1"     pageEncoding="ISO-8859-1"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!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=...

How to get full path of an file or image in Struts2?

String filePath = ServletActionContext.getServletContext().getRealPath("/");