• 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

Regarding servlet init parameter

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends
i have a doubt -how to store servlet init parameter in an attribute

if anybody knows let me know

thanks in advance
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are your doubts?

Init parameters (or any parameters) and attributes are 2 different things.

Please try to explain your doubts more clearly
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello nagalatha mitta,

If you were intended to ask how to store the request parameters to some attributes, you can make use of setAttribute() method to store an attribute. You can retrieve the values using getAttribute() method. These methods are available for the different scopes like session, servletcontext etc. You can choose according to the scenario and need.

These method deal only with objects and NOT primitives. You can read the API for using these method.

Does this help you someway?
[ August 08, 2007: Message edited by: Raghavan Muthu ]
 
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nagalatha

Here is your reply.

See first you have to retrieve servlet init parameter i.e. you have to do something like

String param1 = getServletConfig().getInitParameter(String);



Now, you have got the parameter, you have to store it in an attribte. Depending upon your requirement or the visibility of the attribute, you can store it in various scope. Since you are talking about servlet, I will store it in request scope.
Code will be like this,

request.setAttribute("para1", param1);



Hoping that's what you want.

Regards,
Khushhal
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic