public int CheckParam(HttpServletRequest request, HttpServletResponse response) throws IOException{
PrintWriter out = response.getWriter();
Enumeration e=request.getParameterNames();
while(e.hasMoreElements()){
String parameterName=(String)e.nextElement();
String parameterValue=(String)request.getParameter(parameterName);
if((parameterValue==null) || (parameterValue.trim().length()<1)){
out.println(parameterName+"不可為空<br>");
return -1;
}
}
return 0;
}
public void PrintAllParameters(HttpServletRequest request, HttpServletResponse response) throws IOException{
PrintWriter out = response.getWriter();
Enumeration e=request.getParameterNames();
while(e.hasMoreElements()){
String parameterName=(String)e.nextElement();
String parameterValue=(String)request.getParameter(parameterName);
/* byte b[] = parameterValue.getBytes("ISO-8859-1");
parameterValue = new String(b);
*/ out.print("參數名稱:"+parameterName+"<BR>");
out.print("參數內容:"+parameterValue+"<BR>");
out.print("----------------------------------------------------------------<br>");
}
}
<%
public void PrintAllParameters(HttpServletRequest request, HttpServletResponse response) throws IOException{
PrintWriter out = response.getWriter();
Enumeration e=request.getParameterNames();
while(e.hasMoreElements()){
String parameterName=(String)e.nextElement();
String parameterValue=(String)request.getParameter(parameterName);
out.print("參數名稱:"+parameterName+"<BR>");
out.print("參數內容:"+parameterValue+"<BR>");
out.print("----------------------------------------------------------------<br>");
}
}
%>
<%
Enumeration e=request.getAttributeNames();
while(e.hasMoreElements()){
String attributeName=(String)e.nextElement();
String attributeValue=(String)request.getAttribute(attributeName);
out.print("變數名稱:"+attributeName);
out.print("變數內容:"+attributeValue+"<BR>");
}
%>
String strs = request.getParameter("yourstrs");
byte b[] = strs.getBytes("ISO-8859-1");
strs = new String(b);