• 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

Multiple config parameters within init-param

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a mock Beer-recommendations web app, with a servlet that accesses the init-parameters (servlet config parameters) from the DD, sets them as attributes and forwards the request to a JSP. The JSP retrieves the attributes and prints them to the response stream.


The entire set up works fine and along with the Beer Recommendations, i get the output as
This application has been created by Aniket Patil.

The problem: Instead of having 2 separate <init-param>, i tried to club together both the params i.e. name and lastName into one init-param, as in:

However, now i am only able to access the second param, lastName correctly. If the order of declaration of the params within <init-param> is reversed (i.e. lastName comes first, then name), i am able to access only "name" value correctly i.e. the output is one of

This application has been created by Aniket null.
OR
This application has been created by null Patil.

Can there be only a single init parameter declared within <init-param> at a time, and for multiple declarations, can it access only the last one correctly?
[ January 17, 2007: Message edited by: Aniket Patil ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's funny you don't get a parse error, because only one param-name and param-value is allowed per init-param.
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Satou,

Using Tomcat 5.x, which from my observations reads the DD at server startup, and no parse error is seen then.

Is it mentioned in the spec that only a single param is allowed per init-param? I myself havent been through the spec yet, so would be good if you could post the exact statement from spec to settle the issue for good.
[ January 17, 2007: Message edited by: Aniket Patil ]
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Yes. When you want to define multiple parameters in a single servlet you have to do it the way as shown below.



And the same rule applies when it comes to <context-param> also.

That is when you want to define multiple context parameters you should not put all of then in a single <context-param>.

Rather you need to have different <context-param> block for different context paramater.
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suchen,

Its pretty apparent, inserting multiple params in a single ,<init-param> doesen't work correctly.

Have you come across any documentation(perhaps the Servlet specification), that mentions this?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is it mentioned in the spec that only a single param is allowed per init-param?



Yes it is.
SRV.13.4 Deployment Descriptor Diagram
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found it, thanks!
reply
    Bookmark Topic Watch Topic
  • New Topic