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
242

... - 3rd century - 4th century Decades: 190s 200s 210s 220s 230s - 240s - 250s 260s 270s 280s 290s Years: 237 238 239 240 241 - 242 - 243 244 245 246 ...

 
 
 
This page was created in 22.9 ms