This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP error using tomcat

 
Felipe Walker
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can not get the below code to work
---------------------------------------
jsp
----
<html>
<head>Second Felipe Bean Page</head>
<body>
<jsp:useBean id="test" class="FelipeBean"/>
<p> Your last name is: <%= request.getParameter( "lname" )%>
</body>
</html>

bean
-------
public class FelipeBean{
String name;
public FelipeBean(){
name = "Felipe";
}
public String getName(){
String firstName = name;
return firstName;
}
}


I keep getting the below error
-------------------------------------
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: 4 in the jsp file: /FelipeBean.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\BeanDemo\org\apache\jsp\FelipeBean_jsp.java:45: cannot resolve symbol
symbol : class FelipeBean
location: class org.apache.jsp.FelipeBean_jsp
FelipeBean test = null;
^


An error occurred at line: 4 in the jsp file: /FelipeBean.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\BeanDemo\org\apache\jsp\FelipeBean_jsp.java:47: cannot resolve symbol
symbol : class FelipeBean
location: class org.apache.jsp.FelipeBean_jsp
test = (FelipeBean) _jspx_page_context.getAttribute("test", PageContext.PAGE_SCOPE);
^


An error occurred at line: 4 in the jsp file: /FelipeBean.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\BeanDemo\org\apache\jsp\FelipeBean_jsp.java:49: cannot resolve symbol
symbol : class FelipeBean
location: class org.apache.jsp.FelipeBean_jsp
test = new FelipeBean();
^
3 errors



org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Felipe,

Your jsp cannot resolve the bean properly. Where in the war file is that bean located? Is this bean in the default package?

cheers
skini
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Place the bean in a package other than the default.
 
Felipe Walker
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the information. Do you know of a good site that shows how to setup a WAR file and where to put it once it is created.
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to put the war file in the webapps folder of you tomcat installation. Usually tomcat is setup to pick the war file automatically (hot deployment). So you don't have to deploy anything. If it is not automatically deployed you could go through the server logs for errors or to the tomcat administration to deploy the application manually.
 
Felipe Walker
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the help, I realized the problem was that it was not in a package. During my search I found ANT and that works wonderful to deploy application to Tomcat
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic