This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
1) How are paths built to refer to other files packaged in the same .war file? For example index.html in the root directory of the .war files has the following reference
with the war file unjarred, if index.html is directly accessed the logo file is correctly resolved to the gif file in the images directory. However when accessing it through the J2EE application server ( tomcat 3.2.1 ) the image reference is unresolved. Likewise, I need to specify some xsl files for use by a translation servlet I can do this successfully by using a complete url i.e. http://myHost:8080/examples/servlets/example.xsl but would like to do so using a relative expression so the hostname would not have to be known. (2) is it possible to imbed some xml fragments into the web.xml file? I would like to be able to provide some table like configuration outside of a database.
next question using jaxp with j2ee1.2.2 I am trying to deploy a servlet that relies on the jaxp1.1 extensions on the server provided with the j2sdk1.2.1. What is the appropriate way to resolve that issue. Should I just specifiy jaxp1.1 as a pre req and assume that anyone deploying the web component containing this servlet will have the jaxp1.1 classes in the servers path? or should I packace the jaxp1.1 jar files in the servlet component. If the latter how is that Accomplished? I tried adding all 3 jar files to the web coponent but still get the following error when I run check in the deployment tool. unexpected error in verifier, check for problems related to: [ java.lang.NoClassDefFoundError: javax/xml/transform/TransformerException ]
------------------ Thanks in advance for any help Jeff Gaer
What I've done is to place my image directory at the same level as where the App Server unjars the web app. That way i can say "/images/logo.gif" in my < img src= > tags.
If you wanted to place the images directory within your webapp, I think it could be done, and then simply say "/< webapp dir name >/images/logo.gif"
About your second point, I've noticed the verifier is quite buggy (along with a bunch of other things about the j2sdk1.2.1).
I use the com.oreilly.servlet package, and I've had no trouble including this jar as a Library package (off of the application, not the web component). Have you tried adding it as a Library Component on the Application itself?
p.s. As you might see, you need to leave spaces between your < and >, otherwise UBB tries to turn it into HTML, and drops anything it doesn't like. (or embedd the whole thing in [ code ] blocks) [This message has been edited by Mike Curwen (edited June 04, 2001).]
Joined: Jun 04, 2001
The jaxp stuff works fine if I add it as a jar to the application, but I was hoping to have a self contained application without external dependancies, I thought that was the point of web applications they would install and run on any j2ee compliant as long as they defined and contained all their resources. I'm beginning to feel like J2EE is not yet ready for primetime.
I'm not sure how a library jar file is 'external'.
If you add the jar to the application, then it's not external. It gets put in the .ear file as well, and will be deployed when the .ear file is deployed.
Did you mean something else?
If.. (I'm thinking I see your point now...) you mean that Web Apps don't have a "add to library" button, then you're right .. that's annoying. One should be able to have a .war file contain additional jar's without needing to make it an .ear file.
Joined: Jun 04, 2001
what I mean is I added the jaxp jar files to the <webappl>/library directory, and still got a no classdef found exception when I ran check, or attempted to deploy the application. If I put those jar files in the system classpath, I don't have a problem. I was hoping I could avoid a complex installation process by embedding the requirements in the .war file in the library directory but that does not seem to work.
The check and deploy tools are a bit faulty. My own experience with library jars (particularly if they contain classes that are used by Beans), is that the deploytool will not be able to include the library jars at deploytime when I do an 'update and redeploy'.
But I get a much better result when I undeploy the application, and redeploy it. It's a stupid bug, but the bottom line is, library jars work, if you have the patience to get past the bad tools.
Another path to the same result: Click "update and redploy", wait for the error, dismiss it, and click "update and redploy" again. It should work (if you are having the same problem I had).