Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

How do I obtain a reference to a ServletContext?

Hi,

I've got several applications running within a JBoss 4 Application Server. Two of the applications are actually the same (with slightly difference configurations) so the urls' are of the form:

http://localhost/Application1/Home.do

and

http://localhost/Application2/Home.do

I'm using JMX and MBean management to control and monitor the applications however as both applications are based on the same source code they try to overwrite eachothers mbeans on the mbean server.

What I'd like to do is for the application to determine the name of the servlet context it is running under and name the appropriate MBeans accordingly.

However, I need to be able to obtain a reference to the servlet context outside of a JSP tag and Servlet.

Is there any way of getting a reference to the context the application is running in from within a normal Java class?

Thanks in advance
0
ads_green
Asked:
ads_green
  • 2
1 Solution
 
TimYatesCommented:
>> Is there any way of getting a reference to the context the application is running in from within a normal Java class?

Not that I know of... :-(

You'd have to pass the context through to your class...

Tim
0
 
bloodredsunCommented:
Not in a normal class as it does not have access to either servletconfig or request unless you pass them as TimYates mentioned.

I assume you know how to get the we app names in jsps and servlets?


0
 
TimYatesCommented:
Grade C?

With no comment?

That seems more than a bit harsh :-(
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now