tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes CookieExample.java HelloWorldExample.java JndiServlet.java RequestHeaderExample.java RequestInfoExample.java RequestParamExample.java SessionExample.java servletToJsp.java
Date Fri, 20 Aug 2004 18:42:27 GMT
markt       2004/08/20 11:42:27

  Modified:    webapps/examples/WEB-INF/classes CookieExample.java
                        HelloWorldExample.java JndiServlet.java
                        RequestHeaderExample.java RequestInfoExample.java
                        RequestParamExample.java SessionExample.java
                        servletToJsp.java
  Log:
  Fix bug 6218. Provide support for renaming the examples context without breaking the examples
  Also removed unused imports ID'd by Eclipse.
  
  Revision  Changes    Path
  1.4       +13 -13    jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/CookieExample.java
  
  Index: CookieExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/CookieExample.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CookieExample.java	23 Apr 2002 15:17:25 -0000	1.3
  +++ CookieExample.java	20 Aug 2004 18:42:26 -0000	1.4
  @@ -3,7 +3,6 @@
    */
   
   import java.io.*;
  -import java.text.*;
   import java.util.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
  @@ -36,18 +35,19 @@
           out.println("</head>");
           out.println("<body>");
   
  -	// relative links
  -
  -        // XXX
  -        // making these absolute till we work out the
  -        // addition of a PathInfo issue 
  -	
  -        out.println("<a href=\"/examples/servlets/cookies.html\">");
  -        out.println("<img src=\"/examples/images/code.gif\" height=24 " +
  +        // Can't use relative links as the addition of pathinfo to the URI
  +        // breaks relative links. Therefore use absolute links but don't hard
  +        // code the context name so webapp can be deployed as different context
  +        // and will still work.
  +        String context = request.getContextPath();
  +        
  +        out.println("<a href=\"" + context + "/servlets/cookies.html\">");
  +        out.println("<img src=\"" + context + "/images/code.gif\" height=24 " +
                       "width=24 align=right border=0 alt=\"view code\"></a>");
  -        out.println("<a href=\"/examples/servlets/index.html\">");
  -        out.println("<img src=\"/examples/images/return.gif\" height=24 " +
  -                    "width=24 align=right border=0 alt=\"return\"></a>");
  +        out.println("<a href=\"" + context + "/servlets/index.html\">");
  +        out.println("<img src=\"" + context + "/images/return.gif\" " +
  +                    "height=24 width=24 align=right border=0 alt=\"return\">" +
  +                    "</a>");
   
           out.println("<h3>" + title + "</h3>");
   
  
  
  
  1.3       +14 -16    jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/HelloWorldExample.java
  
  Index: HelloWorldExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/HelloWorldExample.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HelloWorldExample.java	29 Nov 2001 18:27:25 -0000	1.2
  +++ HelloWorldExample.java	20 Aug 2004 18:42:26 -0000	1.3
  @@ -3,7 +3,6 @@
    */
   
   import java.io.*;
  -import java.text.*;
   import java.util.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
  @@ -35,21 +34,20 @@
           out.println("</head>");
           out.println("<body bgcolor=\"white\">");
   
  -	// note that all links are created to be relative. this
  -	// ensures that we can move the web application that this
  -	// servlet belongs to to a different place in the url
  -	// tree and not have any harmful side effects.
  -
  -        // XXX
  -        // making these absolute till we work out the
  -        // addition of a PathInfo issue
  -
  -	    out.println("<a href=\"/examples/servlets/helloworld.html\">");
  -        out.println("<img src=\"/examples/images/code.gif\" height=24 " +
  +        // Can't use relative links as the addition of pathinfo to the URI
  +        // breaks relative links. Therefore use absolute links but don't hard
  +        // code the context name so webapp can be deployed as different context
  +        // and will still work.
  +        String context = request.getContextPath();
  +        
  +	    out.println("<a href=\"" + context + "/servlets/helloworld.html\">");
  +        out.println("<img src=\"" + context + "/images/code.gif\" height=24 " +
                       "width=24 align=right border=0 alt=\"view code\"></a>");
  -        out.println("<a href=\"/examples/servlets/index.html\">");
  -        out.println("<img src=\"/examples/images/return.gif\" height=24 " +
  -                    "width=24 align=right border=0 alt=\"return\"></a>");
  +        out.println("<a href=\"" + context + "/servlets/index.html\">");
  +        out.println("<img src=\"" + context + "/images/return.gif\" " +
  +                    "height=24 width=24 align=right border=0 alt=\"return\">" +
  +                    "</a>");
  +
           out.println("<h1>" + title + "</h1>");
           out.println("</body>");
           out.println("</html>");
  
  
  
  1.3       +1 -4      jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/JndiServlet.java
  
  Index: JndiServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/JndiServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JndiServlet.java	8 Nov 2001 22:02:16 -0000	1.2
  +++ JndiServlet.java	20 Aug 2004 18:42:26 -0000	1.3
  @@ -4,15 +4,12 @@
   
   import java.io.IOException;
   import java.io.PrintWriter;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
   import javax.servlet.*;
   import javax.servlet.http.*;
   import javax.naming.NamingException;
   import javax.naming.Context;
   import javax.naming.InitialContext;
   import javax.naming.NamingEnumeration;
  -import javax.naming.directory.InitialDirContext;
   
   /**
    * Demonstration of the web application environment support.
  
  
  
  1.3       +13 -13    jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/RequestHeaderExample.java
  
  Index: RequestHeaderExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/RequestHeaderExample.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestHeaderExample.java	23 Apr 2002 15:17:25 -0000	1.2
  +++ RequestHeaderExample.java	20 Aug 2004 18:42:26 -0000	1.3
  @@ -3,7 +3,6 @@
    */
   
   import java.io.*;
  -import java.text.*;
   import java.util.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
  @@ -36,18 +35,19 @@
           out.println("</head>");
           out.println("<body>");
   
  -	// all links relative
  -
  -        // XXX
  -        // making these absolute till we work out the
  -        // addition of a PathInfo issue 
  -	
  -        out.println("<a href=\"/examples/servlets/reqheaders.html\">");
  -        out.println("<img src=\"/examples/images/code.gif\" height=24 " +
  +        // Can't use relative links as the addition of pathinfo to the URI
  +        // breaks relative links. Therefore use absolute links but don't hard
  +        // code the context name so webapp can be deployed as different context
  +        // and will still work.
  +        String context = request.getContextPath();
  +        
  +        out.println("<a href=\"" + context + "/servlets/reqheaders.html\">");
  +        out.println("<img src=\"" + context + "/images/code.gif\" height=24 " +
                       "width=24 align=right border=0 alt=\"view code\"></a>");
  -        out.println("<a href=\"/examples/servlets/index.html\">");
  -        out.println("<img src=\"/examples/images/return.gif\" height=24 " +
  -                    "width=24 align=right border=0 alt=\"return\"></a>");
  +        out.println("<a href=\"" + context + "/servlets/index.html\">");
  +        out.println("<img src=\"" + context + "/images/return.gif\" " +
  +                    "height=24 width=24 align=right border=0 alt=\"return\">" +
  +                    "</a>");
   
           out.println("<h3>" + title + "</h3>");
           out.println("<table border=0>");
  
  
  
  1.4       +13 -14    jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/RequestInfoExample.java
  
  Index: RequestInfoExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/RequestInfoExample.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequestInfoExample.java	28 May 2002 14:19:47 -0000	1.3
  +++ RequestInfoExample.java	20 Aug 2004 18:42:26 -0000	1.4
  @@ -3,7 +3,6 @@
    */
   
   import java.io.*;
  -import java.text.*;
   import java.util.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
  @@ -37,19 +36,19 @@
           out.println("</head>");
           out.println("<body bgcolor=\"white\">");
   
  -        // img stuff not req'd for source code html showing
  -	// all links relative!
  -
  -        // XXX
  -        // making these absolute till we work out the
  -        // addition of a PathInfo issue
  -	
  -        out.println("<a href=\"/examples/servlets/reqinfo.html\">");
  -        out.println("<img src=\"/examples/images/code.gif\" height=24 " +
  +        // Can't use relative links as the addition of pathinfo to the URI
  +        // breaks relative links. Therefore use absolute links but don't hard
  +        // code the context name so webapp can be deployed as different context
  +        // and will still work.
  +        String context = request.getContextPath();
  +        
  +        out.println("<a href=\"" + context + "/servlets/reqinfo.html\">");
  +        out.println("<img src=\"" + context + "/images/code.gif\" height=24 " +
                       "width=24 align=right border=0 alt=\"view code\"></a>");
  -        out.println("<a href=\"/examples/servlets/index.html\">");
  -        out.println("<img src=\"/examples/images/return.gif\" height=24 " +
  -                    "width=24 align=right border=0 alt=\"return\"></a>");
  +        out.println("<a href=\"" + context + "/servlets/index.html\">");
  +        out.println("<img src=\"" + context + "/images/return.gif\" " +
  +                    "height=24 width=24 align=right border=0 alt=\"return\">" +
  +                    "</a>");
   
           out.println("<h3>" + title + "</h3>");
           out.println("<table border=0><tr><td>");
  
  
  
  1.3       +13 -15    jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/RequestParamExample.java
  
  Index: RequestParamExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/RequestParamExample.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestParamExample.java	23 Apr 2002 15:17:25 -0000	1.2
  +++ RequestParamExample.java	20 Aug 2004 18:42:26 -0000	1.3
  @@ -3,7 +3,6 @@
    */
   
   import java.io.*;
  -import java.text.*;
   import java.util.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
  @@ -37,20 +36,19 @@
           out.println("</head>");
           out.println("<body bgcolor=\"white\">");
   
  -        // img stuff not req'd for source code html showing
  -
  -	// all links relative
  -
  -        // XXX
  -        // making these absolute till we work out the
  -        // addition of a PathInfo issue 
  -	
  -        out.println("<a href=\"/examples/servlets/reqparams.html\">");
  -        out.println("<img src=\"/examples/images/code.gif\" height=24 " +
  +        // Can't use relative links as the addition of pathinfo to the URI
  +        // breaks relative links. Therefore use absolute links but don't hard
  +        // code the context name so webapp can be deployed as different context
  +        // and will still work.
  +        String context = request.getContextPath();
  +        
  +        out.println("<a href=\"" + context + "/servlets/reqparams.html\">");
  +        out.println("<img src=\"" + context + "/images/code.gif\" height=24 " +
                       "width=24 align=right border=0 alt=\"view code\"></a>");
  -        out.println("<a href=\"/examples/servlets/index.html\">");
  -        out.println("<img src=\"/examples/images/return.gif\" height=24 " +
  -                    "width=24 align=right border=0 alt=\"return\"></a>");
  +        out.println("<a href=\"" + context + "/servlets/index.html\">");
  +        out.println("<img src=\"" + context + "/images/return.gif\" " +
  +                    "height=24 width=24 align=right border=0 alt=\"return\">" +
  +                    "</a>");
   
           out.println("<h3>" + title + "</h3>");
           String firstName = request.getParameter("firstname");
  
  
  
  1.3       +13 -14    jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/SessionExample.java
  
  Index: SessionExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/SessionExample.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SessionExample.java	23 Apr 2002 15:17:25 -0000	1.2
  +++ SessionExample.java	20 Aug 2004 18:42:26 -0000	1.3
  @@ -3,7 +3,6 @@
    */
   
   import java.io.*;
  -import java.text.*;
   import java.util.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
  @@ -36,19 +35,19 @@
           out.println("</head>");
           out.println("<body>");
   
  -        // img stuff not req'd for source code html showing
  -	// relative links everywhere!
  -
  -        // XXX
  -        // making these absolute till we work out the
  -        // addition of a PathInfo issue 
  -	
  -        out.println("<a href=\"/examples/servlets/sessions.html\">");
  -        out.println("<img src=\"/examples/images/code.gif\" height=24 " +
  +        // Can't use relative links as the addition of pathinfo to the URI
  +        // breaks relative links. Therefore use absolute links but don't hard
  +        // code the context name so webapp can be deployed as different context
  +        // and will still work.
  +        String context = request.getContextPath();
  +        
  +        out.println("<a href=\"" + context + "/servlets/sessions.html\">");
  +        out.println("<img src=\"" + context + "/images/code.gif\" height=24 " +
                       "width=24 align=right border=0 alt=\"view code\"></a>");
  -        out.println("<a href=\"/examples/servlets/index.html\">");
  -        out.println("<img src=\"/examples/images/return.gif\" height=24 " +
  -                    "width=24 align=right border=0 alt=\"return\"></a>");
  +        out.println("<a href=\"" + context + "/servlets/index.html\">");
  +        out.println("<img src=\"" + context + "/images/return.gif\" " +
  +                    "height=24 width=24 align=right border=0 alt=\"return\">" +
  +                    "</a>");
   
           out.println("<h3>" + title + "</h3>");
   
  
  
  
  1.2       +0 -1      jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/servletToJsp.java
  
  Index: servletToJsp.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/servletToJsp.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- servletToJsp.java	17 Aug 2000 00:57:53 -0000	1.1
  +++ servletToJsp.java	20 Aug 2004 18:42:27 -0000	1.2
  @@ -1,4 +1,3 @@
  -import javax.servlet.*;
   import javax.servlet.http.*;
   
   public class servletToJsp extends HttpServlet {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message