I transfer a String[] type data into a JSP from a Servlet,String[] is put into
HttpSession,I got String[] in JSP:
String message[];
message=(String[])request.getAttribute("jsp");
In message[],every message has different data and size,for example:
message[0]="animal login";
message[1]="planting open"; //message[1] has size=13;
message[2]="insect login"; //message[0] and message[2] has same size=12;
I transfer message[0],message[1],message[2] into same size,but when I visit JSP,it
show a puzzled display,every button has different size,it shows follows:
********************animal login*************************
********************planting open**************************
********************insect login***********************
I have puzzled it very much,message[0] and message[1] has same size,why it show
different size?
My JSP is follows:
<%@page import="java.io.*"%>
<html>
<title>User Menu</title>
<body>
<%
String message[];
int length;
int location;
message=(String[])request.getAttribute("jsp");
for(int j=0;j<message.length;j++)
{
String show=new String("********************************************************");
length=show.length();
//I want to move message into the center of show
location=(length-message[j].length())/2;
if(location%2==0)
{
show=show.substring(0,location)+message[j]
+show.substring(length-location+1,length);
}
else
{
show=show.substring(0,location)+message[j]
+show.substring(length-location,length);
}
%>
<br>
<input type="button" name=<%=show%> value="<%=show%>" >
<br>
<%
}
%>
</body>
</html>
I don't know where is error? I have another question,when click the first button,I
want to redirect it into a URL,for example http://192.168.2.21:8080/welcome.html.
How to realize it?
Thanks in advance!
Edward
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com