Encyclopedia > JavaServer page example output

  Article Content

JavaServer page example output

For the input, the java code for the resulting servlet class would look something like the following:

 package jsp_servlet;
 import java.util.*;
 import java.io.*;
 import javax.servlet.*;
 import javax.servlet.http.*;
 import javax.servlet.jsp.*;
 import javax.servlet.jsp.tagext.*;

 import com.foo.bar; //imported as a result of <%@ page import="com.foo.bar" %>
 import ...

 class _myserlvet implements javax.servlet.Servlet, javax.servlet.jsp.HttpJspPage {
     //inserted as a
     //result of <%! int serverInstanceVariable = 1;%>
     int serverInstanceVariable = 1; 
     ...

     public void _jspService( javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response )
       throws javax.servlet.ServletException,
              java.io.IOException
     {
         javax.servlet.ServletConfig config = ...;//get the servlet config
         Object page = this;
         PageContext pageContext = ...;//get the page context for this request 
         javax.servlet.jsp.JspWriter out = pageContext.getOut();
         HttpSession session = request.getSession( true );
         try {
             out.print( "<html>\r\n" );
             out.print( "<head>\r\n" );
             ...
             //from <% int localStackBasedVariable = 1; %>
             int localStackBasedVariable = 1; 
             ...
             out.print( "<table>\r\n" );
             out.print( "   <tr><td>" );
             //note, toStringOrBlank() converts the expression into a string or if
             // the expression is null, it uses the empty string.
             //from <%= "expanded inline data " + 1 %>
             out.print( toStringOrBlank( \"expanded inline data \" + 1 ) );
             out.print( "   </td></tr>\r\n" );
             ...
         } catch ( Exception _exception ) {
             //clean up and redirect to error page in <%@ page errorPage="myerror.jsp" %>
         }
    }
 }



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Photosynthesis

... produces a proton-motive force, pumping H+ ions across the membrane; this produces a concentration gradient which can be used to power ATP synthase. This pathway is known ...

 
 
 
This page was created in 26.1 ms