tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mech" <m...@rz.fh-augsburg.de>
Subject RE: Need help w. another jsp!
Date Mon, 10 Feb 2003 00:38:44 GMT
Java teacher says:

As far as I can see, you forgot to wrap your "cases" into brackets...

Try the following:

<% switch (day) { %>
<% case '1': { %>
     <FONT COLOR="blue" SIZE="+1">Sunday</FONT>
     <% break; } %>
<% case '2': { %>
     <FONT COLOR="blue" SIZE="+1">Monday</FONT>
     <% break; } %>
<% case '3': { %>
     <FONT COLOR="blue" SIZE="+1">Tuesday</FONT>
     <% break; } %>
<% case '4': { %>
     <FONT COLOR="blue" SIZE="+1">Wednesday</FONT>
     <% break; } %>
<% case '5': { %>
     <FONT COLOR="blue" SIZE="+1">Thursday</FONT>
     <% break; } %>
<% case '6': { %>
     <FONT COLOR="blue" SIZE="+1">Friday</FONT>
     <% break; } %>
<% case '7': { %>
     <FONT COLOR="blue" SIZE="+1">Saturday</FONT>
     <% break; } %>
<% default: { %>
     <FONT COLOR="blue" SIZE="+1">Error! Bad day!</FONT>
     <% break; } %>
<% } %>


Guess that should work.

Remember what Jasper does with your html tags while generating a servlet
from your jsp file! The generated servlet must contain valid Java. For
every html tag you'll basically have something like an:
out.write("something");

Means you have not just a single statement, you'll most likely get a
block of statements that you have to wrap into brackets {} in order to
make it work and get valid Java code. By the way: Looking in the
generated .java helps to locate such simple problems. Understanding the
way of jsp->servlet processing helps even more. And I don't even start
about using error messages...




And the following code can't work either: Since you didn't import
java.util.Calender you should, of course, also use the fully qualified
class name then for Calendar.getInstance() like you did for
java.util.Random. ;-)
That's why you get "cannot resolve symbol". Try
java.util.Calendar.getInstance()... 
Or why not use <%@ page import="java.util.*" %> instead? Well, forgot...
that requires having read at least the introductory pages of a jsp book
or docu before installing Tomcat...

<%
   // A calendar object is created to get an integer value
   // of the current day of the week
      java.util.Calendar thisCal = Calendar.getInstance();
      int day   = thisCal.get(thisCal.DAY_OF_WEEK);

   // Two arrays are created for demonstrating examples
      String[] wordArray = {"The", "quick", "brown",
                            "fox", ". . ."};
      String[] colorArray = {"red", "green", "blue",
                             "orange",  "black"};

   // Here a random number between 0 and 1 is selected
      java.util.Random rand = new java.util.Random();
      int randomNumber = rand.nextInt(2);
%>


Let's see if that all reduces your error messages... 

Good luck.
Michael

P.S. I guess whenever your project is finished you should write "(c) by
tomcat-user@jakarta.apache.org" below ;-) SCNR

-----Original Message-----
From: Steve Burrus [mailto:burrus1@swbell.net] 
Sent: Montag, 10. Februar 2003 01:02
To: Tomcat Users List
Subject: Re: Need help w. another jsp!


SUCCESS gentlemen with the calendar.jsp!!! I got it to execute in the
Tomcat app. server--probably my very 1st jsp/servlet to successfully
run!!! All that I had to do was to correct a variable name (it had a "-"
in it mistakenly) and then "lo and behold" it ran! I am, however, having
a problem now with another jsp called "ControlFlow.jsp". Here is the 505
server error page:
HTTP Status 500 - 



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: 49 in the jsp file: /ControlFlow.jsp

Generated servlet error:
    [javac] Compiling 1 source file

C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:103: 'case', 'default' or '}' expected
      out.write("\r\n");
      ^



An error occurred at line: 49 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:103: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 50 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:105: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                            ^



An error occurred at line: 50 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:106: 'case', 'default' or '}' expected
      out.write("Sunday");
                                                          ^



An error occurred at line: 51 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:107: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                                   ^



An error occurred at line: 51 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:108: 'case', 'default' or '}' expected
 break; 
      ^



An error occurred at line: 52 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:109: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 53 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:111: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                            ^



An error occurred at line: 53 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:112: 'case', 'default' or '}' expected
      out.write("Monday");
                                                          ^



An error occurred at line: 54 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:113: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                                   ^



An error occurred at line: 54 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:114: 'case', 'default' or '}' expected
 break; 
      ^



An error occurred at line: 55 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:115: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 56 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:117: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                            ^



An error occurred at line: 56 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:118: 'case', 'default' or '}' expected
      out.write("Tuesday");
                                                           ^



An error occurred at line: 57 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:119: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                                   ^



An error occurred at line: 57 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:120: 'case', 'default' or '}' expected
 break; 
      ^



An error occurred at line: 58 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:121: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 59 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:123: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                            ^



An error occurred at line: 59 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:124: 'case', 'default' or '}' expected
      out.write("Wednesday");
                                                             ^



An error occurred at line: 60 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:125: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                                   ^



An error occurred at line: 60 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:126: 'case', 'default' or '}' expected
 break; 
      ^



An error occurred at line: 61 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:127: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 62 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:129: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                            ^



An error occurred at line: 62 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:130: 'case', 'default' or '}' expected
      out.write("Thursday");
                                                            ^



An error occurred at line: 63 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:131: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                                   ^



An error occurred at line: 63 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:132: 'case', 'default' or '}' expected
 break; 
      ^



An error occurred at line: 64 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:133: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 65 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:135: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                            ^



An error occurred at line: 65 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:136: 'case', 'default' or '}' expected
      out.write("Friday");
                                                          ^



An error occurred at line: 66 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:137: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                                   ^



An error occurred at line: 66 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:138: 'case', 'default' or '}' expected
 break; 
      ^



An error occurred at line: 67 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:139: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 68 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:141: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                            ^



An error occurred at line: 68 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:142: 'case', 'default' or '}' expected
      out.write("Saturday");
                                                            ^



An error occurred at line: 69 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:143: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                                   ^



An error occurred at line: 69 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:144: 'case', 'default' or '}' expected
 break; 
      ^



An error occurred at line: 70 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:145: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 71 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:147: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                            ^



An error occurred at line: 71 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:148: 'case', 'default' or '}' expected
      out.write("Error! Bad day!");
                                                                   ^



An error occurred at line: 72 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:149: 'case', 'default' or '}' expected
      out.write("\r\n     ");
                                   ^



An error occurred at line: 72 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:150: 'case', 'default' or '}' expected
 break; 
      ^



An error occurred at line: 73 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:151: 'case', 'default' or '}' expected
      out.write("\r\n");
                       ^



An error occurred at line: 1 in the jsp file: /ControlFlow.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\ControlFlow_jsp.jav
a:45: cannot resolve symbol
symbol  : variable Calendar 
location: class org.apache.jsp.ControlFlow_jsp
      java.util.Calendar thisCal = Calendar.getInstance();
                                   ^
43 errors


	at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHa
ndler.java:130)
	at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.ja
va:293)
	at
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:340)
	at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
	at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.ja
va:474)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja
va:184)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:260)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241
5)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:180)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa
lve.java:170)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:172)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:43
2)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11Protocol.java:386)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:53
4)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:530)
	at java.lang.Thread.run(Thread.java:536)




Attached is the jsp file in question for you to look at/examine. Thank
you very much.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message