JSP and JSTL Tutorials - Tutorial Addendum - JavaServer Pages (JSP)

 31 December 18:00   

    



    



    



    

What is JSP?

    



    

JSP is a technology, not a language. It allows Web page authors to put activating data

    

into a Web certificate with Java statements anchored in appropriate HTML tags. The anchored Java

    

statements will be accomplished by the JSP enabled Web server, not by the Web browser.

    



    

JSP Page is a Web page, HTML document, with enbedded Java statements in a anatomy authentic by the

    

JSP specification. Actuality is a JSP page example, hello.jsp:

    

 

    

<html><body>

    

<% out.println("Hello world!"); %>

    

</body></html>

    



    



    

Line 1 and 3 are accustomed HTML tags. But band 2 is a Java account anchored in appropriate HTML tag.

    



    

We understand how a accustomed Web page is served by a accustomed Web server:

    



        

  • Step 1: The Web browser sends a HTTP appeal to the Web server with the aisle name of

        

    the Web page.

        



  •     

  • Step 2: The Web server picks up the Web page by afterward the defined aisle name.

        



  •     

  • Step 3: The Web server puts the agreeable of the Web page after any changes into

        

    a HTTP response.

        



  •     

  • Step 4: The Web server sends the HTTP acknowledgment to the Web browser.

        



  •     



    



    

Here is how a JSP page is served by a JSP Web server:

    



        

  • Step 1: The Web browser sends a HTTP appeal to the Web server with the aisle name of

        

    the JSP page.

        



  •     

  • Step 2: The Web server checks to see if there is a aggregate adaptation of the requested

        

    JSP page. If no, it compiles the requested JSP page immediately.

        



  •     

  • Step 3: The Web server executes the aggregate adaptation of the requested JSP page, and

        

    collects the achievement of the execution.

        



  •     

  • Step 4: The Web server puts the achievement of the beheading into a HTTP response.

        



  •     

  • Step 5: The Web server sends the HTTP acknowledgment to the Web browser.

        



  •     



    



    

There are two key processes complex in confined a JSP page:

    



        

  • Compilation: A JSP page haveto be aggregate into a Java Servlet class,

        

    before it can be executed. The server can abridge a JSP page in real-time if the page

        

    is requested for the first time, if the page is not pre-compiled.

        



  •     

  • Execution: If a JSP page is requested, its aggregate chic will be accomplished

        

    on the server. The server will forward aback the achievement of the execution, not the agreeable

        

    of the JSP page.

        



  •     



    



    



    

"Hello world!" Java Servlet Class

    



    

To accept added about the JSP accumulation process, let s use my hello.jsp again:

    

 

    

<html><body>

    

<% out.println("Hello world!"); %>

    

</body></html>

    



    



    

Then save hello.jsp to localjakarta-tomcat-4.1.18webappsROOT,

    

and run IE with url: http://localhost:8080/hello.jsp.

    

You should see "Hello world!" in the IE window.

    



    

Now, if you attending at the directory: localjakarta-tomcat-4.1.18workstandalonelocalhost\_,

    

you will see a Java file: hello_jsp.java,

    

 

    

package org.apache.jsp;

    

import javax.servlet.*;

    

import javax.servlet.http.*;

    

import javax.servlet.jsp.*;

    

import org.apache.jasper.runtime.*;

    

public chic hello_jsp extends HttpJspBase {

    

clandestine changeless java.util.Vector _jspx_includes;

    

accessible java.util.List getIncludes() {

    

acknowledgment _jspx_includes;

    

}

    

accessible abandoned _jspService(HttpServletRequest request,

    

HttpServletResponse response)

    

throws java.io.IOException, ServletException {

    

JspFactory _jspxFactory = null;

    

javax.servlet.jsp.PageContext pageContext = null;

    

HttpSession affair = null;

    

ServletContext appliance = null;

    

ServletConfig config = null;

    

JspWriter out = null;

    

Item page = this;

    

JspWriter _jspx_out = null;

    

try {

    

_jspxFactory = JspFactory.getDefaultFactory();

    

response.setContentType("text/html;charset=ISO-8859-1");

    

pageContext = _jspxFactory.getPageContext(this, request, response,

    

null, true, 8192, true);

    

appliance = pageContext.getServletContext();

    

config = pageContext.getServletConfig();

    

affair = pageContext.getSession();

    

out = pageContext.getOut();

    

_jspx_out = out;

    

out.write("<html>");

    

out.write("<body>
");

    

out.println("Hello world!");

    

out.write("
");

    

out.write("</body>");

    

out.write("</html>");

    

} bolt (Throwable t) {

    

out = _jspx_out;

    

if (out != absent && out.getBufferSize() != 0)

    

out.clearBuffer();

    

if (pageContext != null) pageContext.handlePageException(t);

    

} assuredly {

    

if (_jspxFactory != null)

    

_jspxFactory.releasePageContext(pageContext);

    

}

    

}

    

}

    



    

(Continued on next part...)

    



    

 


Tags: pages, world, server, class, browser, write, notes, public, tutorial, tutorials, normal, response

 server, pagecontext, response, servlet, write, jspxfactory, compiled, browser, world, import, javax, sends, execution, requested, request, executed, println, public, class, embedded, output, normal, , web server, jsp page, web page, < body, < html, web browser, http response, write <, javax servlet, jspx out, println hello, path name, import javax, println hello world, import javax servlet, web server puts, path name ofthe, http response step, web server sends, web server with, web browser sends, tutorials tutorial notes, tutorial notes javaserver, notes javaserver pages, web server step, jstl tutorials tutorial,

Share JSP and JSTL Tutorials - Tutorial Addendum - JavaServer Pages (JSP):
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  jsp