JSP: Include parameter transfer receiving and Application

Source: Internet
Author: User

 

First look at a simple application, inA. jspWrite the following code

<Div>

<JSP: Include page = "name. jsp">
<JSP: Param name = "name" value = "XY"/>
</Jsp: Include>

</Div>
This transfers the parameter named name and value XY to name. jsp.

 

InName. jspReceiving Parameters

 
 <%
 String n = request. getparameter ("name ");
 If (n! = NULL &&! "". Equals (N. Trim ()))
 Out. println (N );
 %>

 <Div id = "showname"> <% = URL> </div>

 

Let's look at a paging application.

 

Pager. jsp

<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>
<%
 String Path = request. getcontextpath ();
 String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
%>

<% @ Tagliburi = "/Struts-tags"
Prefix = "S" %>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
 <Head>
  <Base href = "<% = basepath %>">
  </Head>

 <Body>
  <%
   String url = request. getparameter ("url ");
  %>
  <S: If test = "# request. yrlyquery = NULL">
   <S: If test = "data. totalpage> 1">
    <S: If test = "data. totalpage = pageintnum">
     <A href = "<% = URL %>? Pagenum = 1 "> homepage </a> & nbsp;
     <A href = "<% = URL %>? Pagenum = <s: property value = "pageIntNum-1"/> "> previous page </a> & nbsp;
    </S: If>
    <S: elseif test = "pageintnum = 1">
     <A href = "<% = URL %>? Pagenum = <s: property value = "pageintnum + 1"/> "> next page </a>
     <A href = "<% = URL %>? Pagenum = <s: property value = "data. totalpage"/> "> last page </a> & nbsp;
    </S: elseif>
    <S: else>
     <A href = "<% = URL %>? Pagenum = 1 "> homepage </a> & nbsp;
     <A href = "<% = URL %>? Pagenum = <s: property value = "pageIntNum-1"/> "> previous page </a> & nbsp;
     <A href = "<% = URL %>? Pagenum = <s: property value = "pageintnum + 1"/> "> next page </a> & nbsp;
     <A href = "<% = URL %>? Pagenum = <s: property value = "data. totalpage"/> "> last page </a>
    </S: else>
   </S: If>
  </S: If>
  <S: else>
   <S: If test = "data. totalpage> 1">
    <S: If test = "data. totalpage = pageintnum">
     <A href = "<% = URL %>? Querytype = Q & pagenum = 1 "> homepage </a> & nbsp;
     <A href = "<% = URL %>? Querytype = Q & pagenum = <s: property value = "pageIntNum-1"/> "> previous page </a> & nbsp;
    </S: If>
    <S: elseif test = "pageintnum = 1">
     <A href = "<% = URL %>? Querytype = Q & pagenum = <s: property value = "pageintnum + 1"/> "> next page </a> & nbsp;
     <A href = "<% = URL %>? Querytype = Q & pagenum = <s: property value = "data. totalpage"/> "> last page </a>
    </S: elseif>
    <S: else>
     <A href = "<% = URL %>? Querytype = Q & pagenum = 1 "> homepage </a> & nbsp;
       <A href = "<% = URL %>? Querytype = Q & pagenum = <s: property value = "pageIntNum-1"/> "> previous page </a> & nbsp;
        <A href = "<% = URL %>? Querytype = Q & pagenum = <s: property value = "pageintnum + 1"/> "> next page </a>
       <A href = "<% = URL %>? Querytype = Q & pagenum = <s: property value = "data. totalpage"/> "> last page </a>
    </S: else>
   </S: If>
  </S: else>
  Current
  <S: property value = "pageintnum"/>
  Total pages
  <S: property value = "data. totalpage"/>
  Page
 </Body>
</Html>


Here, pagenum and data. totalpage are involved in SSH paging, so we will not go into details here.


Stduent. jsp

......

<Div>
  <JSP: Include page = "../pager. jsp">
  <JSP: ParamName = "url"/value = "Stu/stu_toquery"/>
  </Jsp: Include>
</Div>

......

 

In this way, the paging page can be embedded.

Related Article

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.