Common JSP tags and JSP ing

Source: Internet
Author: User

In order not to clearly write Java code in JSP, JSP still recommends using JSP tags instead of some Java code. Below we will list two simple JSP tags for a look: Jump tag and additional parameter tag.
 
[Java]
<% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" contentType = "text/html; charset = UTF-8" %>
 
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> common JSP labels </title>

</Head>

<Body>
<% Int x = 10; %>

<Jsp: forward page = "/index. jsp"> <% -- jump tag -- %>
<Jsp: param value = "xxxx" name = "username"/> <% -- you can use this label to bring the previous value in the jump tag -- %>
<Jsp: param value = "<% = x %>" name = "username1"/> <% -- you can use this expression to include the past value -- %>

</Jsp: forward>



</Body>
</Html>
<% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" contentType = "text/html; charset = UTF-8" %>
 
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> common JSP labels </title>

</Head>
 
<Body>
<% Int x = 10; %>
 
<Jsp: forward page = "/index. jsp"> <% -- jump tag -- %>
<Jsp: param value = "xxxx" name = "username"/> <% -- you can use this label to bring the previous value in the jump tag -- %>
<Jsp: param value = "<% = x %>" name = "username1"/> <% -- you can use this expression to include the past value -- %>
 
</Jsp: forward>
 
 
 
</Body>
</Html>
 
For JSP ing, like Servlet ing, configure the XML document to complete the ing. Let's take a look at the code below.
 
[Java]
<Servlet>
<Servlet-name> xxx </servlet-name>
<Jsp-file>/1.jsp</jsp-file>
</Servlet>

<Servlet-mapping>
<Servlet-name> xxx </servlet-name>
<Url-pattern>/888.html </url-pattern>
</Servlet-mapping>
<Servlet>
<Servlet-name> xxx </servlet-name>
<Jsp-file>/1.jsp</jsp-file>
</Servlet>
 
<Servlet-mapping>
<Servlet-name> xxx </servlet-name>
<Url-pattern>/888.html </url-pattern>
</Servlet-mapping>
In this case, 888.htmlis equivalent to the 1.jspweb page. Actually, 888.html does not exist.
 
From technology is my lifelong pursuit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.