• 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

Acces to tomcat context in thread

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Tomcat application, I read the parameters of the web.xml file with this lines:



But when I throw a new Thread the thread can't read it. How can I set thread to read the context of the tomcat application?

Thanks in advance
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm guessing that you're implementing a web service using Axis, since that's where MessageContext comes from.

The message context is probably only valid in the thread that handles the WS invocation. If you want to use that information in some other thread, get it in the WS thread, and pass it to the newly created thread, either in the constructor or via setters.
 
alain martin
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes I'm using axis.

Your proposal doesn't like me very much, I would like doing it more clean...

how could I read the web.xml file directly from the thread?

thanks
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

alain:how could I read the web.xml file directly from the thread?


Well nothing stops you from reading a file on the file system! However, you would need to know which web.xml to read i.e. the path of the file on the filesystem.
This means that the thread reading the web.xml needs to be passed some contextual information, and this is exactly what Ulf suggested.
You may choose to pass the file path and read web.xml yourself or just passed the ServletContext that will read the xml for you.
The choice is yours, but indeed the sensible one will be to pass the ServletContext!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The choice is yours, but indeed the sensible one will be to pass the ServletContext!


I disagree. The ServletContext object should not be passed to other components. The proper thing to do is to retrieve those data items that are of interest from the context, and then pass those to the newly created thread.
[ February 21, 2008: Message edited by: Ulf Dittmer ]
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic