• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding servlet init parameter

 
nagalatha mitta
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • 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
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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 ]
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic