• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Organizing large JSP into smaller chunks

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to put the class in a package other than the nameless "default" package.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic