Add to Favorites    Make Home Page 3260 Online  
 Language Categories  
 Our Services  

Home » Java Home » Algorithms Home » Guest Book Application Using Servlets

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Guest Book Application Using Servlets
Author Satish.K
Author Email fly_sati [at] yahoo.co.in
Description
Category Java » Algorithms
Hits 427881
Code Select and Copy the Code
// guestbk.java // import java.sql.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class guestbk extends httpservlet { Connection con; public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException { PrintWriter out=new PrintWriter(res.getOutputStream()); int ctr=0; res.setContentType("text/html"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:booksrc","",""); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from gbook"); out.println("<Html>"); out.println("<Head>"); out.println("<Title>GuestBook</Title>"); out.println("</Head>"); out.println("<Table border=1 align=center >"); out.println("<H4><B><center>GUEST BOOK DETAILS </center></B></H4><BR>"); out.println("<TR><TD><b>E-Mail Address</b></TD><TD><b>Comment</b></TD></TR>"); while(rs.next()) { ctr++; String email=rs.getString("emailid"); String cmt=rs.getString("comment"); out.println("<TR><TD>"+email+"</TD><TD>"+cmt+"</TD></TR>"); } out.println("</Table>"); if(ctr==0) out.println("<BR>No Records Found<BR>"); stmt.close(); con.close(); } catch(SQLException SQLExcep) { System.out.println("error"); } catch(ClassNotFoundException CNFE) { System.out.println("error"); } out.println("</Html>"); out.close(); } } // submit.java // import java.sql.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class submit extends HttpServlet { Connection con; public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException { String str1,str2; str1=req.getParameter("emailid"); str2=req.getParameter("comment"); System.out.println(str1); System.out.println(str2); res.setContentType("text/html"); PrintWriter out=res.getWriter(); out.println("<html><h2>Guest Book is Successfully Updated</h2></html>"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:booksrc","",""); Statement stmt=con.createStatement(); ResultSet rs; int i= stmt.executeUpdate("insert into gbook values('"+str1+"','"+str2+"')"); if(i==1) { System.out.println("ok"); } stmt.close(); con.close(); } catch(SQLException SQLExcep) { System.out.println("error"); } catch(ClassNotFoundException CNFE) { System.out.println("error"); }} } //guestbk.htm// <Html> <Head> <Title>GUEST BOOK</Title> </Head> <Body> <P> <Center> <Form Action= "http:\localhost:8080servletguestbk" Method= "POST"> <Input Type="Submit" Value="VIEW THE GUEST BOOK"> </Form> <BR> <Form action= "http:\localhost:8080servletsubmit" method= "Post"> ENTER YOUR EMAIL ADDRESS<Br> <Input Type="text" Name="emailid" Size="40"><BR> COMMENTS ARE ALWAYS WELCOME<BR> <TextArea Name="comment" Rows="8" Cols="65"></TextArea> </Center> <P> <P> <BR> <P> <Center> <Input Type="Submit" Value="Submit"> </Form> <Input Type="Reset" Value="Reset"> </Center> <BR> </Body> </Html>

Related Source Codes

Script Name Author
Sending mail Using JavaMail to Yahoo and Gmail accounts sai prasad
Simple Program in Java to Implement Multithreading Satish.K
Simple Calculator in Java Using Remote Method Invocation Satish.K
String Manipulation Using Stringification Satish.K
String Manipulation Using Stringification Satish.K
Moving Ball Application Using Java Beans Satish.K
Rapid Roll game subrahmanyeswararao
student mgm arpan
Sourav Datta
Download Manager Sagar
Address Book in Java Rahul Chouhan
address book using java database connectivity(jdbc-msaccess) shekhar bansal
sun Steganography B.Rajavel
Connecting Java with MS-Access - Inserting data in Aseem
Address Book in Java Rahul Chouhan

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1226


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review