List:Commits« Previous MessageNext Message »
From:tony.bedford Date:July 7 2010 4:53pm
Subject:svn commit - mysqldoc@docsrva: r21615 - in trunk/sample-programs/connector-j-tutorials: . HelloWebServlet HelloWebServlet/WEB-INF HelloWebServlet/WEB-...
View as plain text  
Author: tbedford
Date: 2010-07-07 18:53:25 +0200 (Wed, 07 Jul 2010)
New Revision: 21615

Log:
Basic working servlet with Glassfish XML.

Added:
   trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/classes/HelloWebServlet.java
   trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/classes/LocalStrings.properties
   trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/sun-web.xml
   trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/web.xml
   trunk/sample-programs/connector-j-tutorials/HelloWebServlet/images/duke.waving.gif
   trunk/sample-programs/connector-j-tutorials/HelloWebServlet/index.html

Property changes on: trunk/sample-programs/connector-j-tutorials/HelloWebServlet/images/duke.waving.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream


Added: trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/classes/HelloWebServlet.java
===================================================================
--- trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/classes/HelloWebServlet.java	                        (rev 0)
+++ trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/classes/HelloWebServlet.java	2010-07-07 16:53:25 UTC (rev 21615)
Changed blocks: 1, Lines Added: 62, Lines Deleted: 0; 2077 bytes

@@ -0,0 +1,62 @@
+import javax.servlet.http.*;
+import java.io.*;
+
+public class HelloWebServlet extends HttpServlet {
+
+  public void doPost(HttpServletRequest req, HttpServletResponse resp){
+    try {    
+      resp.setContentType("text/html");
+      PrintWriter writer = resp.getWriter();
+      writer.println("<html><body>");
+      writer.println("<p>Hello from servlet doPost()</p>");
+      writer.println("</body></html>");
+      writer.close(); 
+    }
+    catch (Exception e) {
+      e.printStackTrace();
+    }  
+  }
+
+  public void doGet(HttpServletRequest req, HttpServletResponse resp){
+    try {    
+      resp.setContentType("text/html");
+      PrintWriter writer = resp.getWriter();
+      writer.println("<html><body>");
+      writer.println("<p>Hello from servlet doGet()</p>");
+      writer.println("</body></html>");
+      writer.close(); 
+    }
+    catch (Exception e) {
+      e.printStackTrace();
+    }  
+  }
+
+}
+
+/*
+  InitialContext ctx;
+  DataSource ds;
+  Connection conn;
+  Statement stmt;
+  ResultSet rs;
+
+  try {
+    ctx = new InitialContext();
+    ds = (DataSource) ctx.lookup("java:comp/env/jdbc/MySQLDataSource");
+    //ds = (DataSource) ctx.lookup("jdbc/MySQLDataSource");
+    conn = ds.getConnection();
+    stmt = conn.createStatement();
+    rs = stmt.executeQuery("SELECT * FROM Country");
+
+    while(rs.next()) {
+    System.out.println(""+rs.getString("Name"));
+    System.out.println(""+rs.getString("Population"));
+    }
+  }
+  catch (SQLException se) {
+    System.out.println(""+se.getMessage());
+  }
+  catch (NamingException ne) {
+    System.out.println(""+ne.getMessage());  
+  }
+*/  
\ No newline at end of file


Added: trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/classes/LocalStrings.properties
===================================================================
--- trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/classes/LocalStrings.properties	                        (rev 0)
+++ trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/classes/LocalStrings.properties	2010-07-07 16:53:25 UTC (rev 21615)
Changed blocks: 1, Lines Added: 3, Lines Deleted: 0; 582 bytes

@@ -0,0 +1,3 @@
+#Default resource bundle for english locale
+greeting_message=Hi, my name is Duke. What's yours?
+greeting_response=Hello


Added: trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/sun-web.xml
===================================================================
--- trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/sun-web.xml	                        (rev 0)
+++ trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/sun-web.xml	2010-07-07 16:53:25 UTC (rev 21615)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 826 bytes

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app>
+  <context-root>HelloWebServlet</context-root>
+  <resource-ref>
+    <res-ref-name>jdbc/MySQLDataSource</res-ref-name>
+    <jndi-name>jdbc/MySQLDataSource</jndi-name>  
+  </resource-ref> 
+</sun-web-app>


Added: trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/web.xml
===================================================================
--- trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/web.xml	                        (rev 0)
+++ trunk/sample-programs/connector-j-tutorials/HelloWebServlet/WEB-INF/web.xml	2010-07-07 16:53:25 UTC (rev 21615)
Changed blocks: 1, Lines Added: 25, Lines Deleted: 0; 1438 bytes

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" 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-app_2_4.xsd">
+  <display-name>HelloWebServlet</display-name>  
+  <distributable/>
+  <resource-ref>
+    <res-ref-name>jdbc/MySQLDataSource</res-ref-name>
+    <res-type>javax.sql.DataSource</res-type>
+    <res-auth>Container</res-auth>
+    <res-sharing-scope>Shareable</res-sharing-scope>                
+  </resource-ref>
+  <servlet>
+        <servlet-name>HelloWebServlet</servlet-name>
+        <servlet-class>HelloWebServlet</servlet-class>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>HelloWebServlet</servlet-name>
+        <url-pattern>/HelloWebServlet</url-pattern>
+    </servlet-mapping>
+    <session-config>
+        <session-timeout>30</session-timeout>
+    </session-config>
+    <welcome-file-list>
+        <welcome-file>index.html</welcome-file>
+    </welcome-file-list>
+</web-app>


Added: trunk/sample-programs/connector-j-tutorials/HelloWebServlet/images/duke.waving.gif
===================================================================


Changed blocks: 0, Lines Added: 0, Lines Deleted: 0; 395 bytes


Added: trunk/sample-programs/connector-j-tutorials/HelloWebServlet/index.html
===================================================================
--- trunk/sample-programs/connector-j-tutorials/HelloWebServlet/index.html	                        (rev 0)
+++ trunk/sample-programs/connector-j-tutorials/HelloWebServlet/index.html	2010-07-07 16:53:25 UTC (rev 21615)
Changed blocks: 1, Lines Added: 15, Lines Deleted: 0; 728 bytes

@@ -0,0 +1,15 @@
+<html>
+  <head><title>HelloWebServlet</title></head>
+  
+  <body>
+    <h1>HelloWebServlet</h1>
+    
+    <p>Please enter your name:</p>
+    
+    <form action="HelloWebServlet" method="POST">
+      <input type="text" name="username" length="40" />
+      <input type="submit" value="submit" />
+    </form>
+    
+  </body>
+</html>
\ No newline at end of file


Thread
svn commit - mysqldoc@docsrva: r21615 - in trunk/sample-programs/connector-j-tutorials: . HelloWebServlet HelloWebServlet/WEB-INF HelloWebServlet/WEB-...tony.bedford7 Jul