File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes getServletContext().getContent() returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "getServletContext().getContent() returning null" Watch "getServletContext().getContent() returning null" New topic
Author

getServletContext().getContent() returning null

Chandella Montero
Ranch Hand

Joined: Feb 18, 2011
Posts: 89
I have created two web applications to test getting the ServletContext of one application from within another application.

Code for the first Servlet, from the first application:



This will print the path "/MyServlets", which I will use in the second Servlet, as well as "from within the same servlet, flavour is: vanilla", which proves that this value has been set (I set it in the deployment descriptor).

Now here is the code for the second Servlet, which lives in the second application:


What am I doing wrong?

Thanks in advance for your help


OCA, OCP Java 6
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1678
    
  25

Hi Chandella,

What am I doing wrong?

If you are using Tomcat as a server you have to put the following line in either the server.xml or better the context.xml of your server:

Regards,
Frits
Chandella Montero
Ranch Hand

Joined: Feb 18, 2011
Posts: 89
Spot on, added that line to context.xml and it now works

Thank you ever so much, Frits!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getServletContext().getContent() returning null