-2

This code contains no errors while compiling but gives errors while running it. I am not able to run this code on tomcat 7.0. I started restarting it several times. Can you suggest me any ideas how to change the code so that it works?

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
  </head>
  <%@ page import="java.util.*" %>
    <body>
      <form action="MyWSserve" method="get">Enter Zip Code
        <br>
        <input type="text" name="zipcode"></input>
        <input type="submit" name="GO" value="GO"></input>
      </form>
      <% //Object obj=request.getAttribute("values"); 
      //if(obj instanceof ArrayList){ 
        //ArrayList<String>mylist = (ArrayList<String>)obj; }%>
      <% //Iterator<String>itr = mylist.iterator(); %>
      <% String[] strcode=(String[])request.getAttribute( "values"); %>
      <p>The Temperature in Centigrade <%=strcode[0] %><br></p>
      <p>The Temperature in Farenheit <%=s trcode[1] %><br></p>
      <p>The Pressure is <%=s trcode[2] %><br></p>
      <p>The weather Condition is <%=s trcode[3] %><br></p>
    </body>
</html>
4

1 回答 1

0

尝试这个:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
  </head>
  <%@ page import="java.util.*" %>
    <body>
      <form action="MyWSserve" method="get">Enter Zip Code
        <br>
        <input type="text" name="zipcode"></input>
        <input type="submit" name="GO" value="GO"></input>
      </form>
      <% //Object obj=request.getAttribute("values"); 
      //if(obj instanceof ArrayList){ 
        //ArrayList<String>mylist = (ArrayList<String>)obj; }%>
      <% //Iterator<String>itr = mylist.iterator(); %>
      <% String[] strcode = request.getParameterValues("values"); %>
      <% if (strcode != null && strcode.length >= 4) { %>
      <p>The Temperature in Centigrade <%=strcode[0] %><br></p>
      <p>The Temperature in Farenheit <%= strcode[1] %><br></p>
      <p>The Pressure is <%= strcode[2] %><br></p>
      <p>The weather Condition is <%= strcode[3] %><br></p>
      <% } else { %>
      <p>Call this page using 4 parameters called "values":
      <a href="?values=1st&values=2nd&values=3rd&values=4th">?values=1st&values=2nd&values=3rd&values=4th</a>
      <% } %>
    </body>
</html>
于 2013-04-23T03:12:19.437 回答