File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

who can help me in a example

 
greg jiang
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Carl Trusiak
Sheriff
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Axel Janssen
Ranch Hand
Posts: 2166
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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)?
 
Aaradhna Saxena
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic