JSP test Page

Source: Internet
Author: User
Tags tostring
JS <%--
Author:diegoyun
Date:2005-1-21
DESC:JSP test Page
--%>
<%@ page contenttype= "text/html; CHARSET=GBK "%>
<%@ page import= "Java.util.Enumeration,
Java.util.Iterator,
Java.util.Collection,
Java.util.ArrayList "%>
<p>
<table width= "100%" border= "1" cellpadding= "3" cellspacing= "0" bordercolor= "#000000" >
<tr>
&LT;TD width= "20%" bgcolor= "#CCCCCC" >request uri</td>
<%
Get Request URI and put it in a string
String RequestUri = Request.getrequesturi ();
%>
&LT;TD bgcolor= "#33CCFF" ><%=requestUri%></td>
</tr>
</table>
<br>
<table width= "100%" border= "1" cellpadding= "3" cellspacing= "0" bordercolor= "#000000" >
<tr bgcolor= "#0099FF" >
&LT;TD colspan= "2" >request parameter</td>
</tr>
<tr>
&LT;TD width= "20%" bgcolor= "#CCCCCC" >parameter name</td>
&LT;TD bgcolor= "#33CCFF" >parameter value</td>
</tr>
<%
Enumeration enparanames = Request.getparameternames ();
String sparaname = "";
String sparavalue = "";
while (Enparanames.hasmoreelements ())
{
Sparaname = (String) enparanames.nextelement ();
%>
<tr>
&LT;TD bgcolor= "#CCCCCC" ><%=sParaName%></td>
<%
String[] sparavalues;
Sparavalues = Request.getparametervalues (sparaname);
int i;
for (i = 0;i<sparavalues.length;i++)
{
if (i = = 0)
{
Sparavalue = Sparavalues[i];
}
Else
{
Sparavalue = Sparavalue + "," + sparavalues[i];
}
}
if (sparavalue.length () = = 0)
{
Sparavalue = "";
}
%>
&LT;TD bgcolor= "#33CCFF" ><%=sParaValue%></td>
</tr>
<%}%>
</table>
<br>
<table width= "100%" border= "1" cellpadding= "3" cellspacing= "0" bordercolor= "#000000" >
<tr bgcolor= "#0099FF" >
&LT;TD colspan= "2" >request attribute</td>
</tr>
<tr>
&LT;TD width= "20%" bgcolor= "#CCCCCC" >attribute name</td>
&LT;TD bordercolor= "#000000" bgcolor= "#33CCFF" >attribute value</td>
</tr>
<%
Enumeration enattrnames = Request.getattributenames ();
String sattrname = "";
String sattrvalue = "";
while (Enattrnames.hasmoreelements ())
{
Sattrname = (String) enattrnames.nextelement ();
%>
<tr>
&LT;TD bgcolor= "#CCCCCC" ><%=sAttrName%></td>
<%
Object OBJX = Request.getattribute (sattrname);
if (objx instanceof String)
{
Sattrvalue = (String) objx;
}
Else
{
Sattrvalue = Objx.tostring ();
}

if (sattrvalue.length () = = 0)
{
Sattrvalue = "";
}

%>
&LT;TD bgcolor= "#33CCFF" ><%=sAttrValue%></td>
</tr>
<%}%>
</table>
<br>
<table width= "100%" border= "1" cellpadding= "3" cellspacing= "0" bordercolor= "#000000" >
<tr bgcolor= "#0099FF" >
&LT;TD colspan= "2" >session attribute</td>
</tr>
<tr>
&LT;TD width= "20%" bgcolor= "#CCCCCC" >attribute name</td>
&LT;TD bgcolor= "#33CCFF" >attribute value</td>
</tr>
<%
Enumeration ensesnames = Session.getattributenames ();
String ssesname = "";
String ssesvalue = "";
while (Ensesnames.hasmoreelements ())
{
Ssesname = (String) ensesnames.nextelement ();
%>
<tr>
&LT;TD width= "20%" bgcolor= "#CCCCCC" ><%=sSesName%></td>
<%
Object o = Session.getattribute (ssesname);
if (o instanceof String)
{
Ssesvalue = (String) o;
}
Else
{
Ssesvalue = O.tostring ();
}

if (ssesvalue.length () = = 0)
{
Ssesvalue = "";
}

%>
&LT;TD bgcolor= "#33CCFF" ><%=sSesValue%></td>
</tr>
<%}%>
</table>
</p>








Author blog:http://blog.csdn.net/walkingwithjava/


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.