servlet sample projects

i am a java programmer working on JDBC & Swing API. i want myself exposed to projects in Servlet API. So i any of u can provide me a sample project on Servlet it will be much helpful.
magdom_khajaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AHadiAConnect With a Mentor Commented:
u can impleament a webmail service by servlet it has good new point to learn .
u can touch me and i  will give u more information.
0
 
brlmutiaCommented:
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
//import java.util.*;


public class DBRead extends HttpServlet
    implements SingleThreadModel
{
    String resultsDir;
   
    public void init(ServletConfig config)
      throws ServletException {

      super.init(config);
      
    }
   

    public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException
    {

      res.setContentType("text/html");

        PrintWriter toClient = res.getWriter();

        try {

          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

          Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@150.10.50.8:1521:orcl",
                                             "scott", "tiger");

          Statement stmt = conn.createStatement ();

          ResultSet rset = stmt.executeQuery ("select * from EMP");
      
          toClient.println("<HTML> <BODY>" );
          
          while (rset.next ()) {
            toClient.println ("<BR>" + rset.getString (1) + "   " + rset.getString (2) + "   " +
                                 rset.getString (3) + "   " + rset.getString (4) + "   " +
                                 rset.getString (5) + "   " + rset.getString (6) + "   " +
                                 rset.getString (7) + "   " + rset.getString (8) );
          }
          
          toClient.println("</BODY> </HTML>");
          
          toClient.close();
          conn = null;
          
      } catch(SQLException e) {

          e.toString();         
          
        }
      
    }
}

0
All Courses

From novice to tech pro — start learning today.