Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Organizing large JSP into smaller chunks

 
Robin Clark
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to organize a very large JSP into smaller more organized chunks. However, when I implement some of the functionality in a separate java class, my jsp will not compile successfully because it can not see the new class. I have successfully compiled the java class and installed the .class file in my web application's WEB-INF/classes directory. I even created a jar file with the new class and placed it in the web application's WEB-INF/lib directory and the Tomcat common/lib directory. I've stopped and started Tomcat as well.
Here is an excerpt from the jsp:

The error that I get is when compiling the last statement that instantiates the UtteranceInfo object. The error message is:

Here is an excerpt for the code for the UtteranceInfo class:
 
Robin Clark
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I accidently submitted that post before I finished editting it. Here is the correct code excerpt from the UtteranceInfo class:

This is the first time that I have ever tried to instantiate a java class from within my jsp. I am using Tomcat 4.0.6 on Windows 2000 server.
Thank you very much for your help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to put the class in a package other than the nameless "default" package.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you probably also need to add another line
<%@page import="whatever.UtteranceInfo"%>
so that your JSP knows where to look for the class.
 
Robin Clark
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I am having trouble putting these pieces together. I have created a new directory WEB-INF/classes/utterance. In this directory is my .class file for my java class. I changed the java class to add a package statement to the top. Is this the correct syntax for the package statement?

In my jsp, I added an import directive like this:

I bounced Tomcat, but I still get the following error when I try to execute
my jsp in a browser:

I am confused a bit further because I am trying to do this in Eclipse and I don't understand what it is doing when I try to create a new package, "utterance" under the WEB-INF/classes directory when my project is at the web application root level. What it does is create a directory under the web application root level for the .java file, then it places the .class file in the WEB-INF/classes/utterance directory. But I guess that question should be directed to the IDE forum.
Any help would be greatly appreciated.
 
Robin Clark
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that I figured this out. My import directive in the jsp was wrong. It should have been:

I think that I am trying to learn too many new things at one time:
Java
JSP
VoiceXML
Eclipse
Tomcat
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic