aspose file tools*
The moose likes JSP and the fly likes web.xml parameters? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "web.xml parameters?" Watch "web.xml parameters?" New topic
Author

web.xml parameters?

Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Init parameters declared within a servlet declaration are specific to that servlet. If you want "global" parameters, you should be using context parameters.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
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

Joined: Jan 10, 2002
Posts: 61648
    
  67

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

Joined: Feb 06, 2008
Posts: 204
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

Joined: Jan 10, 2002
Posts: 61648
    
  67

No. There is no API for that.
 
 
subject: web.xml parameters?