Posts

Showing posts from September, 2014

Give Url to ur servlet through @WebServlet(name = "Controller", urlPatterns = {"/Controller"})

@WebServlet(name = "Controller", urlPatterns = {"/Controller"}) public class Controller extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) { }  protected void doGet(HttpServletRequest request, HttpServletResponse response)             throws ServletException, IOException {         processRequest(request, response);     } protected void doPost(HttpServletRequest request, HttpServletResponse response)             throws ServletException, IOException {         processRequest(request, response);     } }

remove .jsp extension through web.xml

<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">     <servlet>         <servlet-name>New</servlet-name>         <servlet-class>Connect.New</servlet-class>     </servlet>     <servlet-mapping>         <servlet-name>New</servlet-name>         <url-pattern>/New</url-pattern>     </servlet-mapping>     <servlet>     <servlet-name>login</servlet-name>     <jsp-file>/login.jsp</jsp-file>  </servlet>  <servlet-mapping>      <servlet-name>login</servlet-name>      <url-pattern>/login</url-pattern>  </servlet-mapping>    <servlet>     <ser

Hello World in springs

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> <bean id="dao" class="naveen.Dao"> <property name="name" value="Naveen" /> </bean> </beans>

Dependency Inject in springs

Interface. package depend; public interface Naveen { public void printe(); } Class package depend; public class Jyoti implements Naveen { @Override public void printe() { System.out.print("Naveen && Jyoti"); } } Helper Class package depend; public class Output { Naveen naveen; public void setNaveen(Naveen naveen) { this.naveen = naveen; }  public void printe()  { naveen.printe();  } } applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> <bean id="dao" class="na

@import in springs examples.

package multiconfig; public class Naveen { public void print(String msg) { System.out.print("Naveen"+msg); } } package multiconfig; public class Jyoti { public void print(String msg) { System.out.print("Naveen"+msg); } } package multiconfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class Naveenconfig { @Bean(name="naveen") public Naveen n() { return new Naveen(); } } package multiconfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class Jyoticonfig { @Bean(name="jyoti") public Jyoti j() { return new Jyoti(); } } package multiconfig; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotatio

@Configuration,@Bean(name="helloBean") in springs example,this is remove configuration through xml into java class.

package javaconfig; public interface HelloNaveen { void print(String msg); } its implementation class package javaconfig; public class Hello implements HelloNaveen { @Override public void print(String msg) { System.out.println("Hello"+msg); } } package javaconfig; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Bean; @Configuration public class Appconfig { @Bean(name="helloBean") public HelloNaveen hello1() { return new Hello(); } } package javaconfig; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class Main { public static void main(String[] args) { ApplicationContext tx=new AnnotationConfigApplicationContext(Appconfig.class); Hello h=(Hello)tx.getBean("he

Hello World in springs

applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> <bean id="dao" class="naveen.Dao"> <property name="name" value="Naveen" /> </bean> </beans> package naveen; public class Dao { public String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public void print() { System.out.print("Hello"+name); } } package main; import naveen.Dao; import org.springframework.context.ApplicationContext; import org.springframework.context.support

The libs.CopyLibs.classpath property is not set up. This property must point to

libs.CopyLibs.classpath=C\:/Program Files/NetBeans 8.0/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar set this in yor netbeans  go to netbeans tools>options> java tab and add properties libs.CopyLibs.classpath=C\:/Program Files/NetBeans 8.0/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar 

Order By in mysql.

select * from inventory order by Product_Name

create pdf of jpanel through itext.jar

 try   {     Document document   = new Document();     PdfWriter writer    = PdfWriter.getInstance(document, new FileOutputStream("e:/test.pdf"));     document.open();     PdfContentByte contentByte = writer.getDirectContent();     PdfTemplate template = contentByte.createTemplate(jPanel10.getWidth(), jPanel10.getHeight());     Graphics2D g2 = template.createGraphics(jPanel10.getWidth(), jPanel10.getHeight());     jPanel10.print(g2);     g2.dispose();     contentByte.addTemplate(template, 5, 60);     document.close();   }   catch(Exception e)   {       System.out.println(e);   }

Generate JPanel as a PDF.

 try   {     Document document   = new Document();     PdfWriter writer    = PdfWriter.getInstance(document, new FileOutputStream("e:/test.pdf"));     document.open();     PdfContentByte contentByte = writer.getDirectContent();     PdfTemplate template = contentByte.createTemplate(600, 600);     Graphics2D g2 = template.createGraphics(600, 600);     jPanel10.print(g2);     g2.dispose();     contentByte.addTemplate(template, 40, 400);     document.close();   }   catch(Exception e)   {       System.out.println(e);   }

ORA-12519, TNS:no appropriate service handler found

Restart the Database. And check the all closed.  closeSession(); Reason - there are two many open connection.

Get Image From Database Value.

    <%       EmployeeDao ee=new EmployeeDao();       List list=ee.View();       Iterator<Employee> itr=list.iterator();       %>             <center>             <table style="width:100px;" border="2">                 <th>EMP_NAME</th>                 <th>EMP_NATION</th><th>EMP_ADDRESS</th><th>EMP_MOBILE</th><th>EMP_MAILID</th>                 <th>EMP-CONTRACT-TYPE</th><th>EMP-JOIN-DATE</th><th>COMPLETION-DATE</th><th>PHOTO</th><th>DELETE</th><th>UPDATE</th>                           <%       while(itr.hasNext())       {           Employee e=itr.next();           %>            <tr>           <td><%=e.getName()%></td>           <td><%=e.getNation()%></td>           <td><%=e.getAddress()%></td>           <td><%=e.getMobi

Hibernate Delete Query.

Session session=getSession();         Transaction t=session.beginTransaction();         Query q=session.createQuery("delete from Employee e where e.id='"+id+"'");         q.executeUpdate();          t.commit();         closeSession();

Get Record from Database Behalf on Id through Hibernate.

 Session session= getSession();         Transaction t = session.beginTransaction();       Query q= session.createQuery("from Employee e where e.id='"+id+"'");       List<Employee> list= q.list();         t.commit();         closeSession();         return list;

Save Image Path And Data in Database through Hibernate.

index.jsp <%@page import="java.util.Iterator"%> <%@page import="java.util.List"%> <%@page import="org.hibernate.SessionFactory"%> <%@page import="org.hibernate.cfg.Configuration"%> <%@page import="EMPLOYEE.*"%> <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html>     <head>         <title>Payroll management System</title>         <meta charset="UTF-8">         <meta name="viewport" content="width=device-width, initial-scale=1.0">         <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />         <link rel="stylesheet" href="jquery-ui.css" />   <script src="ht