For faster navigation, this Iframe is preloading the Wikiwand page for JavaServer Pages.

JavaServer Pages

JavaServer Pages ir servera puses Java tehnoloģija, kas ļauj izveidot dinamiski ģenerētas tīmekļa lapas HTML, XML vai citā formātā. Arhitektoniski JSP var skatīt kā Java servleta augsta līmeņa abstrakciju. Tehnoloģiju izstrādājusi Sun Microsystems 1990. gadu beigās.

JSP ļauj statiskā tīmekļa lapā iekļaut Java kodu vai EL formātā rakstītus fragmentus. Kad tīmekļa klients pieprasa lapu, to JSP Servlet Engine apstrādā un izveido servleta pirmkodu, kas ir Java klase. Tad to kompilē Java baitkodā, kuru izpilda Java Virtual Machine. Nākamreiz, kad lietotājs pieprasa šo pašu lapu, tiek palaists iepriekš nokompilētais kods. Tādējādi pirmoreiz lapa veras lēnāk, bet nākamās reizes ātrāk. Ja pirmkods tiek mainīts, tad to no jauna kompilē. JSP pirmkods var arī tikt uzreiz interpretēts, netērējot laiku kompilēšanai, kas ir izdevīgi izstrādes laikā.

Piemērs

JSP pirmkoda fragments:

 <%@ page errorPage="myerror.jsp" %>
 <%@ page import="com.foo.bar" %>
 
 <html>
 <head>
 <%! int serverInstanceVariable = 1;%>
 
 <% int localStackBasedVariable = 1; %>
 <table>
 <tr><td><%= toStringOrBlank( "expanded inline data " + 1 ) %></td></tr>

Izveidotais servlets:

 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 _myservlet 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>" );
            // From <%= toStringOrBlank( "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" %>
        }
    }
 }

Ārējās saites

Wikibooks
Wikibooks
Wikibooks ir grāmata par šo tēmu
{{bottomLinkPreText}} {{bottomLinkText}}
JavaServer Pages
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?