Win a copy of Learning Regular Expressions this week in the General Computing 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

web.xml parameters?  RSS feed

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am try to get the initial parameters from the web.xml file.
Also want to know how to get other tags from the ServletContext.

I do

In my jsp page. And it is not getting the value "com.mycompany.myapp.actions"

Here is my web.xml file


I found that when I call context.getServletContextName() it prints out
the <display-name>StreamBurner Webapp</display-name> in my jsp.

Maybe initial Parameters are only meant for inside servlet tags ???
If is then how do I set initial parameter's for all jsp and servlets in the web.xml file?

Any help would be great.
 
Author and ninkuma
Marshal
Posts: 66807
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Init parameters declared within a servlet declaration are specific to that servlet. If you want "global" parameters, you should be using context parameters.
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok , figured it out

by using this snippet in the web.xml

I was able to get the values.

However I also have tags like <error-page> , <welcome-file> , and <session-config>. What are this? I cann't get them with getInitParameter .

What are these I don't think these are context parameters?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66807
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sam Doder:
What are these I don't think these are context parameters?


If they're not declared with <context-parameter>, then yeah, they're not context parameters.

I'm not sure exactly what your question is.

If you want to know what all the components of the deployment descriptor are, the Servlet Spec is the document for you.
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I mean is I want to beable to get the values of these tags.

Like say I have

<welcome-file-list id="WelcomeFileList">
<welcome-file>ping.jsp</welcome-file>
</welcome-file-list>

in the web.xml

How would I get the welcome-file value (which is ping.jsp ) from a jsp or servlet?

Their are other tags that you can put into the web.xml (other then config-param , or servlet tags )

I was wondering if their is an yes way to get these tag values from a jsp or servlet? Like say you had a filter, or an error page and you wanted to get the name of the error page in the jsp or servlet.

I know you can just but another config-param tag but I was wondering if you can do it straight from the tag.(Without parsing it's xml )
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66807
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. There is no API for that.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!