File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes who can help me in a example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "who can help me in a example" Watch "who can help me in a example" New topic

who can help me in a example

greg jiang

Joined: May 08, 2002
Posts: 5
I practic the sample in core servlets/jsp using init(config)to get param from web server.but I have set the web.xml,I could not get parma through config.getInitParameter in servlet.Maybe this example in core and more servlets/jsp.Who have done this successful?I use jbuilder6 so the web server is tomcat.who can halp me ,thanks.
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
Two objects have the method getInitParameter. ServletConfig and Servlet. Which one you use depends on where you placed the parameter in the web.xml.
If it is within the servlet tags, you use the method on Servlet. This is useful for parameters that are specific to a single Servlet/JSP and have no meaning to other parts of the system.
If it defined within the context-param, you use the ServletConfig object and it is available to all the servlets and jsp within your application.

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
greg jiang

Joined: May 08, 2002
Posts: 5
thanks Carl
I just use ServletConfig.getInitParameter in a servlet init(ServletConfig config)to get a init value of a servlet.I config web.xml and add<servletname><servletclass>and so on,just like the Core-Servlets-JSP said. but I could not get the param like the book said.I do not know how to do.
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Hi Greg,
this can't be to difficult.
You may post your servlet java code and the web.xml here.
Please don't forget put it in code in Instand UBB Code Code tags and activate checkbox "Disable smilies in this post"
greg jiang

Joined: May 08, 2002
Posts: 5
The example is in the 2.7chapter in core servlet/jsp.I think it is right but I could not get the result.Maybe it is a problem in configing the tomcat.I use jbuilder6 enterprise it use tomcat as a web server.the web.xml file is the <default webapp>/deployment discriptors/web.xml.I hope someone who are familior the configure of jbuilder or tomcat could help me.thank a lot.
the procedure init

greg jiang

Joined: May 08, 2002
Posts: 5
I have got a clue.If I use <servlet-mapping> map my class into a /servlet/myclass model and use the alias in browser, the result is right.but the book did say this,I still wanna know if this is difference bettween tomcat 3.0 to tomcat 3.2.3(jbuilder6 used)?
Aaradhna Saxena

Joined: Apr 29, 2002
Posts: 6
Initialization parameters can only be accessed if the servlets are accessed through their registered names or custom URLs...
That might be the reason!

Sun Certified Web Component Developer<br />Sun Certified Java Programmer<br />Brainbench Master Level Certified for EJB
I agree. Here's the link:
subject: who can help me in a example
jQuery in Action, 3rd edition