Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

getServletContext().getContent() returning null

 
Ranch Hand
Posts: 238
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
T Vergilio
Ranch Hand
Posts: 238
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spot on, added that line to context.xml and it now works

Thank you ever so much, Frits!
 
This will take every ounce of my mental strength! All for a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic