• 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

who can help me in a example

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
greg jiang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
Axel
 
greg jiang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 edition.so 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

web.xml
 
greg jiang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Initialization parameters can only be accessed if the servlets are accessed through their registered names or custom URLs...
That might be the reason!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic