This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to pass initParameter to the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to pass initParameter to the servlet" Watch "How to pass initParameter to the servlet" New topic
Author

How to pass initParameter to the servlet

Doshi Milan
Ranch Hand

Joined: May 29, 2001
Posts: 112
Hello,
I would like to pass some init parameters to the servlet, such that I can later retrieve it through the
ServletContext context =getServletContext();
String paraRetrieved=context.getInitParameter("SOMENAME");
:
My probelem is how to initialise/send the Parameters?
Also I am getting a strange probelem when I write:
context.setAttribute("Name",new String("Milan"));
stating that method() setAttribute(String, String) not found!
I am using JSDK2.0.
Please guide me.
Thanx,
Milan Doshi
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You have to use some kind of external mechanism such as a file or database. The specifics on doing this could vary depending on the webserver you are using.

Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

check the post i just made here: http://www.javaranch.com/ubb/Forum7/HTML/000638.html
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: How to pass initParameter to the servlet
 
It's not a secret anymore!