The if else statement inside my jsp is not working, it gives me the following error:
Code:
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 51 in the jsp file: /website/weather.jsp Generated servlet error: The operator > is undefined for the argument type(s) String, int org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 51 in the jsp file: /website/weather.jsp Generated servlet error: The operator > is undefined for the argument type(s) String, int org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414) org.apache.jasper.compiler.Compiler.compile(Compiler.java:297) org.apache.jasper.compiler.Compiler.compile(Compiler.java:276) org.apache.jasper.compiler.Compiler.compile(Compiler.java:264) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
Code:
<%@ page import="java.util.*,java.io.*" %>
<html>
<head>
<meta http-equiv="refresh" content="10">
<LINK REL="stylesheet" TYPE="text/css" HREF="stylesheet1.css">
</head>
<body>
<hr></hr>
<center>
<h1>
Weather Forecast</h1>
<br>
<a href="test.html"> Local Five day forecast </a>
<br><br>
<table border=1 cellpadding=5 cellspacing=0 width="50%">
<tr><th colspan=2>Todays Temperature </th></tr>
<tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
<%
String tempString;
BufferedReader dataFile1 = null;
try {
//String[] temp = {"Temperature", "Light"};
int recCount1 = 0;
FileReader dFile1 = new FileReader("w:/www/DataFile1.txt");
dataFile1 = new BufferedReader(dFile1);
tempString = dataFile1.readLine();
%>
<% if (tempString > 30) { %>
<img src="sunny.gif">
<% } else { %>
<img src="rainy.gif">
<%} %>
<tr><th>Temperature (Degree Celsius) :</th> <td><%=tempString%></td></tr>
<%
while(tempString != null){
%>
<%
recCount1++;
tempString = dataFile1.readLine();
}
}
catch (FileNotFoundException e) {
System.err.println("FileStreamsTest: " + e);
}
catch(IOException iOE) {
iOE.printStackTrace();
}
finally {
dataFile1.close();
}
%>
</table>
<br><br><br>
<table border=1 cellpadding=5 cellspacing=0 width="50%">
<tr><th colspan=2>Todays Light Intensity</th></tr>
<tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
<%
String valString;
BufferedReader dataFile = null;
try {
int recCount = 0;
FileReader dFile = new FileReader("w:/www/DataFile2.txt");
dataFile = new BufferedReader(dFile);
valString = dataFile.readLine();
%>
<tr><th>Light Intensity (Lux) :</th><td><%=valString%></td> </tr>
<%
while(valString != null){
%>
<%
recCount++;
valString = dataFile.readLine();
}
}
catch (FileNotFoundException e) {
System.err.println("FileStreamsTest: " + e);
}
catch(IOException iOE) {
iOE.printStackTrace();
}
finally {
dataFile.close();
}
%>
</table>
<br>
<br>
<br>
<br>
<br>
<br>
<hr></hr>
</body>
</html>
Comment