Hibernate Architecture
Hibernate architecture has three main components:
- Connection Management
- Transaction management
- Object relational mapping:
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
XML
file for its configuration. You can’t give any name to this file, this file is usually calledbuild.xml
. It builds are based on three blocks: tasks, targets and extension points .<target name="compile">
...................
</target>
<target name="run" depends="compile">
...................
</target>
build.xml
file you can specify the default target. Ant will execute this target, if no explicit target is specified.package javabynataraj; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; public class ExampleTag extends SimpleTagSupport { public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); out.print("<b>Hello World!</b>"); } }
<?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0"> <tlib-version>1.0</tlib-version> <short-name>csajsp-taglib</short-name> <tag> <description>Example tag</description> <name>example</name> <tag-class>package.TagHandlerClass</tag-class> <body-content>empty</body-content> </tag> </taglib>
<prefix:tag/> or <prefix:tag></prefix:tag>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Example JSP page</TITLE> <LINK REL=STYLESHEET HREF="JSP-Styles.css" TYPE="text/css"> </HEAD> <BODY> <%@ taglib uri="/WEB-INF/tlds/example.tld" prefix="test" %> <test:example/> <test:example></test:example> </BODY></HTML>
<pg:pager maxPageItems="10" prevNextUrl="/myproj/auto/sheetAuditResults.do" url="/myproj/auto/sheetAuditResults.do" name="caseResponseForm"> ------- ------------ </pg:pager>
<jsp:useBean id="pnUrlName" class="java.lang.String" scope="page" /> <jsp:useBean id="urlName" class="java.lang.String" scope="page" /> <%pnUrlName = request.getContextPath()+"/auto/sheetAuditResults.do"; %> <%urlName = request.getContextPath()+"/auto/sheetAuditResults.do"; %> <pg:pager maxPageItems="10" prevNextUrl="<%=pnUrlName %>" url="<%=urlName %>" name="auditInformationResultsResponseForm">
<img src="/myproj/images/calbtn.gif" border="0" alt="popup selection calendar ">We have to change the static contextPath /myproj to dynamically.
<%@ taglib uri="/WEB-INF/tlds/struts-core.tld" prefix="c" %> <c:set var="path" value="${pageContext.request.contextPath}"/>
<img src="<c:out value="${path}"/>/images/calbtn.gif" border="0" alt="popup selection calendar">
caseWindow = window.open('/myapp/cases/displayCase.do?previousPage=addDeposit'+jsessionId,' DN_modalEms','width=800,height=600,resizable=yes, scrollbars=yes,status=yes,menubar=no,toolbar=no,modal=yes');
<c:set var="path" value="${pageContext.request.contextPath}"/>use the contextPath in the javascript function:
<script type="text/javascript"> contextPath = '<c:out value="${path}"/>'; </script>
modalCaseWindow = window.open(contextPath+'/cases/displayCreateCase1.do?previousPage=addDeposit'+jsessionId,'DN_modalEms', 'width=800,height=600,resizable=yes,scrollbars=yes, status=yes,menubar=no,toolbar=no,modal=yes');
<a href="/myproj/updateMyDeviceId.do?device=' + ent.deviceId + '">';Change the static context root reference to dynamic contextPath for the hyperlink in jsp file as given below.
<a href="'+ contextPath +'/updateMyDeviceId.do?device=' + ent.deviceId + '">';
if (data.status == 1) { $('#status').text('Enabled'); $('#circle').attr('src', '/myproj/images/green-circle.png') $('#statusButton').val('Disable'); }Change the context path in the if condition. For this define a variable as ctx to get contextPath using request.getContextPath() method.
<script>var ctx = "<%=request.getContextPath()%>"</script>Declare the ctx variable below to the taglib uri tags then we can use any where in the program.
if (data.status == 1) { $('#status').text('Enabled'); $('#circle').attr('src',ctx+'/images/green-circle.png') $('#statusButton').val('Disable'); }
doGet
|
doPost
|
In doGet Method the parameters are appended to the URL and sent along with header information
|
In doPost parameters are sent in separate line in the body
|
Maximum size of data that can be sent using doget is 240 bytes
|
There is no maximum size for data
|
Parameters are not encrypted
|
Parameters are encrypted
|
DoGet method generally is used to query or to get some information from the server
|
DoPost is slower compared to doGet since doPost does not write the content length
|
DoGet should be idempotent. i.e. doget should be able to be repeated safely many times
|
This method does not need to be idempotent. Operations requested through POST can have side effects for which the user can be held accountable for example updating stored data or buying items online.
|
DoGet should be safe without any side effects for which user is held responsible.
|
This method does not need to be either safe.
|
<%@ 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> <form name="fileuploadform" action="http://localhost:8080/UploadCSV/uploadfile">Upload CSV File<br> Select the header file to upload <input type="file" name="filehdr" /><br> Select the detail file to upload <input type="file" name="filedtl" /><br> Please select a folder to which the file has to be uploaded. <input type="file" name="filefolder" /><br> <input type="submit" name="submit" value="submit"> </form> </html>
<%@ 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> <b>The Files has been Uploaded into particular tables.</b> </body> </html>
package com; import java.sql.Connection; import java.sql.DriverManager; public class DBConnection { static Connection con; public static Connection getConnection(){ con=null; try{ System.out.println("----------I am in DBConnection----------"); Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection("jdbc:mysql://192.168.1.101:3306/test?user=test&password=test" ); System.out.println("---------end of DBConnection----------"); }catch(Exception e){ e.getMessage(); } return con; } }
package com; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class SaveFile extends HttpServlet { public void init(ServletConfig config)throws ServletException{ super.init(config); System.out.println("The SaveFile iniated.^^^^^^^^^^^^^^^^^^^################"); } public void service(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException{ try{ String pathheader=request.getParameter("filehdr"); System.out.println("The pathheader is : "+pathheader); String pathdetail=request.getParameter("filedtl"); System.out.println("The pathdetail is : "+pathdetail); String folderpath=request.getParameter("filefolder"); String filenamehdr=folderpath+pathheader.substring(pathheader.lastIndexOf('\\')); System.out.println("The file output path is : "+filenamehdr); String filenamedtl=folderpath+pathdetail.substring(pathdetail.lastIndexOf('\\')); System.out.println("The file output path is : "+filenamedtl); FileInputStream fis=new FileInputStream(pathheader); FileOutputStream fos=new FileOutputStream(filenamehdr); byte buf[]=new byte[11024]; fis.read(buf); fos.write(buf,0,buf.length); fis=new FileInputStream(pathdetail); fos=new FileOutputStream(filenamedtl); fis.read(buf); fos.write(buf,0,buf.length); if(fis!=null) fis.close(); if(fos!=null) fos.close(); System.out.println("------------------ Files are Saved in Folder-------------------"); request.getRequestDispatcher("/uploaddata").forward(request, response); }catch(FileNotFoundException e){ System.out.println(e.getMessage()); }catch(IOException e){ System.out.println(e.getMessage()); } } }
package com; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.StringTokenizer; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class UploadFile2DB extends HttpServlet { public void init(ServletConfig config) throws ServletException{ super.init(config); System.out.println("The UploadDataServlet2 iniated."); } public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException { String filepathhdr=request.getParameter("filehdr"); String filepathdtl=request.getParameter("filedtl"); Connection con=DBConnection.getConnection(); System.out.println("connection=----------->"+con); PreparedStatement pstmthdr=null; PreparedStatement pstmtdtl=null; int rowshdr=0; BufferedReader brhdr=new BufferedReader(new FileReader(filepathhdr)); BufferedReader brdtl=new BufferedReader(new FileReader(filepathdtl)); System.out.println("reading the file"); String strLineHdr=""; String strLineDtl=""; String hdrstr=""; String dtlstr=""; StringTokenizer sthdr=null; StringTokenizer stdtl=null; // String firstColumnData[]=new String[10]; int lineNumberHdr=0; int lineNumberDtl=0; // int line=1; try{ pstmthdr=con.prepareStatement("insert into omts_onlinehdr values (?,?,?,?,?,?,?)"); System.out.println("statement executed"); while((strLineHdr=brhdr.readLine())!=null){ System.out.println("HEADERLINE"+strLineHdr); int i=1; if(!(lineNumberHdr==0)){ sthdr=new StringTokenizer(strLineHdr,","); while(sthdr.hasMoreTokens()){ hdrstr=sthdr.nextToken(); System.out.println("HeaderString: "+hdrstr); pstmthdr.setString(i++,hdrstr); System.out.println("below insertion"); } rowshdr=pstmthdr.executeUpdate(); System.out.println(rowshdr+" rows updated."); } lineNumberHdr++; } System.out.println("not in detail"); pstmtdtl=con.prepareStatement("insert into omts_onlinedtl values (?,?,?,?,?,?,?)"); System.out.println("ps executed"); while((strLineDtl=brdtl.readLine())!=null){ System.out.println("detailLINE"+strLineDtl); int i=1; if(!(lineNumberDtl==0)){ stdtl=new StringTokenizer(strLineDtl,","); while(stdtl.hasMoreTokens()){ dtlstr=stdtl.nextToken(); System.out.println("detail: "+dtlstr); pstmtdtl.setString(i++,dtlstr); System.out.println("below insertion"); } int rowsdtl=pstmtdtl.executeUpdate(); System.out.println(rowsdtl+" rows are updated."); } lineNumberDtl++; } //con.commit(); } catch(Exception e){ System.out.println(e.getMessage()); } finally { try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } response.sendRedirect("http://localhost:8080/UploadCSV/succ.jsp"); } }