tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@locus.apache.org
Subject cvs commit: jakarta-tomcat-4.0/webapps/examples/servlets jndi.html index.html
Date Thu, 02 Nov 2000 06:17:25 GMT
remm        00/11/01 22:17:24

  Modified:    webapps/examples/servlets index.html
  Added:       webapps/examples/servlets jndi.html
  Log:
  - Link the new JNDI sevlet example from the servlet examples index page
  
  Revision  Changes    Path
  1.2       +8 -0      jakarta-tomcat-4.0/webapps/examples/servlets/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/servlets/index.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- index.html	2000/08/17 00:58:20	1.1
  +++ index.html	2000/11/02 06:17:24	1.2
  @@ -89,6 +89,14 @@
   </tr>
   
   <tr VALIGN=TOP>
  +<td>Naming</td>
  +
  +<td WIDTH="30%"><a href="../servlet/JndiServlet"><img SRC="../images/execute.gif"
HSPACE=4 BORDER=0  align=TOP></a><a href="../servlet/JndiServlet">Execute</a></td>
  +
  +<td WIDTH="30%"><a href="jndi.html"><img SRC="../images/code.gif" HSPACE=4
BORDER=0 height=24 width=24 align=TOP></a><a href="jndi.html">Source</a></td>
  +</tr>
  +
  +<tr VALIGN=TOP>
   <td>Sessions</td>
   
   <td WIDTH="30%"><a href="../servlet/SessionExample"><img SRC="../images/execute.gif"
HSPACE=4 BORDER=0  align=TOP></a><a href="../servlet/SessionExample">Execute</a></td>
  
  
  
  1.1                  jakarta-tomcat-4.0/webapps/examples/servlets/jndi.html
  
  Index: jndi.html
  ===================================================================
  <html>
  <head>
  <title>Untitled Document</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>
  
  <body bgcolor="#FFFFFF">
  <p><font color="#0000FF"><a href="../servlet/JndiServlet"><img src="../images/execute.gif"
align="right" border="0"></a><a href="index.html"><img src="../images/return.gif"
width="24" height="24" align="right" border="0"></a></font></p>
  <h3>Source Code for Naming Example<font color="#0000FF"><br>
    </font> </h3>
  <font color="#0000FF"></font> 
  <pre>
  <font color="#0000FF">import</font> java.io.IOException;
  <font color="#0000FF">import</font> java.io.PrintWriter;
  <font color="#0000FF">import</font> java.util.Enumeration;
  <font color="#0000FF">import</font> java.util.Hashtable;
  <font color="#0000FF">import</font> javax.servlet.*;
  <font color="#0000FF">import</font> javax.servlet.http.*;
  <font color="#0000FF">import</font> javax.naming.NamingException;
  <font color="#0000FF">import</font> javax.naming.Context;
  <font color="#0000FF">import</font> javax.naming.InitialContext;
  <font color="#0000FF">import</font> javax.naming.NamingEnumeration;
  <font color="#0000FF">import</font> javax.naming.directory.InitialDirContext;
  
  <font color="#CC0000">/**
   * Demonstration of the web application environment support.
   *
   * @author Remy Maucherat
   */</font>
  
  <font color="#0000FF">public class</font> JndiServlet 
      <font color="#0000FF">extends</font> HttpServlet {
  
  
      <font color="#0000FF">public void</font> doGet(HttpServletRequest request,
HttpServletResponse response)
          <font color="#0000FF">throws</font> ServletException, IOException {
          
          PrintWriter out = response.getWriter();
          response.setContentType(&quot;<font color="#009900">text/plain</font>&quot;);
          
          Context ctx = null;
          
          <font color="#0000FF">try</font> {
              ctx = new InitialContext();
          } <font color="#0000FF">catch</font> (NamingException e) {
              out.println(&quot;<font color="#009900">Couldn't build an initial
context : </font>&quot; + e);
              return;
          }
          
          <font color="#0000FF">try</font> {
              Object value = ctx.lookup(&quot;<font color="#009900">java:/comp/env/maxExemptions)</font>&quot;;
              out.println(&quot;<font color="#009900">Simple lookup test : </font>&quot;);
              out.println(&quot;<font color="#009900">Max exemptions value : </font>&quot;
+ value);
          } <font color="#0000FF">catch</font> (NamingException e) {
              out.println(&quot;<font color="#009900">JNDI lookup failed : </font>&quot;
+ e);
          }
          
          <font color="#0000FF">try</font> {
              Context envCtx = (Context) ctx.lookup(&quot;<font color="#009900">java:/comp/env/</font>&quot;);
              out.println(&quot;<font color="#009900">list() on /comp/env Context
: </font>&quot;);
              NamingEnumeration enum = ctx.list(&quot;<font color="#009900">java:/comp/env/</font>&quot;);
              while (enum.hasMoreElements()) {
                  out.print(&quot;<font color="#009900">Binding : </font>&quot;);
                  out.println(enum.nextElement().toString());
              }
              out.println(&quot;<font color="#009900">listBindings() on /comp/env
Context : </font>&quot;);
              enum = ctx.listBindings(&quot;<font color="#009900">java:/comp/env/</font>&quot;);
              while (enum.hasMoreElements()) {
                  out.print(&quot;<font color="#009900">Binding : </font>&quot;);
                  out.println(enum.nextElement().toString());
              }
          } <font color="#0000FF">catch</font> (NamingException e) {
              out.println(&quot;<font color="#009900">JNDI lookup failed : </font>&quot;
+ e);
          }
          
      }
      
      
  }
  </pre>
  </body>
  </html>
  
  
  

Mime
View raw message