A pair of curly brackets constitute a logical block. A variable declared inside a block is visible within that block and the blocks contained in that block. In your case the place where you are using the variable myname is outside the block where u declared it. Hence the problem. Can you please paste the code that you have written after moving it up one block. With all the blocks intact though. Regards, Gaurav Singh Kushwaha http://www.chakpak.com Ph: +91-9880110695 Bangalore, India. On 2/3/07, Pid wrote: > > can you provide another test case, or an example of a real exception? > > variables defined inside the try/catch aren't available outside of it, > so maybe you're using them inside it normally. > > > Jason Friedman wrote: > > Russell, > > > > I tried that but seems the same problem is still there. > > > > I used to define lots of variables inside try/catch and it works > > for all JSP pages. Honestly I dont think there is a problem with > > the code. My machine is Linux btw. > > > > > > On 2/2/07, Pitre, Russell wrote: > >> You have the "myname" variable declared inside the try/catch statement. > >> Try declaring it outside of the try/catch. > >> > >> > >> <%@ page language="java" contentType="text/html" > >> import=" java.util.*,java.io.*,java.sql.*"%> > >> <% > >> String myname: > >> try{ > >> myname = "Jason"; > >> }catch(Exception e){ > >> e.printStackTrace(); > >> } > >> %> > >> > >> > >> This is a html, my name is <%=myname%> > >> > >> > >> -----Original Message----- > >> From: Jason Friedman [mailto:ysonglist@gmail.com] > >> Sent: Friday, February 02, 2007 2:47 PM > >> To: users@tomcat.apache.org > >> Subject: Tomcat and JSP Issue > >> > >> My tomcat works perfectly normal before today. I did nothing to it, > >> but now even the simplest JSP code gives errors: > >> > >> whatswrong.jsp > >> ======================================================= > >> <%@ page language="java" contentType="text/html" > >> import=" java.util.*,java.io.*,java.sql.*"%> > >> <% > >> try{ > >> String myname = "Jason"; > >> }catch(Exception e){ > >> e.printStackTrace(); > >> } > >> %> > >> > >> > >> This is a html, my name is <%=myname%> > >> > >> ======================================================= > >> > >> Here are the errors: > >> ======================================================= > >> HTTP Status 500 -type Exception reportmessage > >> > >> 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: 20 in the jsp file: /whatswrong.jsp > >> > >> Generated servlet error: > >> [javac] Compiling 1 source file > >> > >> /home/yasong/apache-tomcat-4.1.34 > /work/Standalone/localhost/_/whatswrong > >> _jsp.java:57: > >> cannot resolve symbol > >> symbol : variable myname > >> location: class org.apache.jsp.whatswrong_jsp > >> out.print(myname); > >> ^ > >> 1 error > >> at > >> org.apache.jasper.compiler.DefaultErrorHandler.javacError > (DefaultErrorHa > >> ndler.java:85) > >> at > >> org.apache.jasper.compiler.ErrorDispatcher.javacError( > ErrorDispatcher.ja > >> va:248) > >> at > >> org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:343) > >> at > >> org.apache.jasper.compiler.Compiler.compile(Compiler.java:356) > >> at > >> org.apache.jasper.JspCompilationContext.compile( > JspCompilationContext.ja > >> va:427) > >> at > >> org.apache.jasper.servlet.JspServletWrapper.service( > JspServletWrapper.ja > >> va:142) > >> at > >> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java > :240) > >> at > >> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187) > >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:809) > >> at > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter > (Applica > >> tionFilterChain.java:198) > >> at > >> org.apache.catalina.core.ApplicationFilterChain.doFilter > (ApplicationFilt > >> erChain.java:144) > >> at > >> org.apache.catalina.core.StandardWrapperValve.invoke > (StandardWrapperValv > >> e.java:209) > >> at > >> > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i > >> nvokeNext(StandardPipeline.java:595) > >> at > >> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java > :4 > >> 32) > >> at > >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954) > >> at > >> org.apache.catalina.core.StandardContextValve.invoke > (StandardContextValv > >> e.java:138) > >> at > >> > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i > >> nvokeNext(StandardPipeline.java:595) > >> at > >> org.apache.catalina.valves.CertificatesValve.invoke( > CertificatesValve.ja > >> va:197) > >> at > >> > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i > >> nvokeNext(StandardPipeline.java:593) > >> at > >> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java > :4 > >> 32) > >> at > >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954) > >> at > >> org.apache.catalina.core.StandardContext.invoke(StandardContext.java > :245 > >> 9) > >> at > >> org.apache.catalina.core.StandardHostValve.invoke( > StandardHostValve.java > >> :132) > >> at > >> > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i > >> nvokeNext(StandardPipeline.java:595) > >> at > >> org.apache.catalina.valves.ErrorDispatcherValve.invoke > (ErrorDispatcherVa > >> lve.java:118) > >> at > >> > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i > >> nvokeNext(StandardPipeline.java:593) > >> at > >> org.apache.catalina.valves.ErrorReportValve.invoke( > ErrorReportValve.java > >> :116) > >> at > >> > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i > >> nvokeNext(StandardPipeline.java:593) > >> at > >> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java > :4 > >> 32) > >> at > >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954) > >> at > >> org.apache.catalina.core.StandardEngineValve.invoke > (StandardEngineValve. > >> java:126) > >> at > >> > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i > >> nvokeNext(StandardPipeline.java:595) > >> at > >> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java > :544 > >> ) > >> at > >> > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i > >> nvokeNext(StandardPipeline.java:593) > >> at > >> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java > :4 > >> 32) > >> at > >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954) > >> at > >> org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152) > >> at > >> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java > :86 > >> 9) > >> at > >> > org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.proc > >> essConnection(Http11BaseProtocol.java:664) > >> at > >> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket > (PoolTcpEndpoint > >> .java:527) > >> at > >> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt > (LeaderFollow > >> erWorkerThread.java:80) > >> at > >> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run > (ThreadPool > >> .java:684) > >> at java.lang.Thread.run(Thread.java:534) > >> > >> Apache Tomcat/4.1.34 > >> ======================================================= > >> > >> --------------------------------------------------------------------- > >> To start a new topic, e-mail: users@tomcat.apache.org > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > >> For additional commands, e-mail: users-help@tomcat.apache.org > >> > >> > >> --------------------------------------------------------------------- > >> To start a new topic, e-mail: users@tomcat.apache.org > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > >> For additional commands, e-mail: users-help@tomcat.apache.org > >> > >> > > > > --------------------------------------------------------------------- > > To start a new topic, e-mail: users@tomcat.apache.org > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > > For additional commands, e-mail: users-help@tomcat.apache.org > > > > > > > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > >