Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getServletConfig().getInitParameter("name2") returns null in a forwarded servlet

 
Serafim Plishas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I start servlet Transit1 and forward it to Transit2
both take their paramete from ServletConfig (this.getServletConfig().getInitParameter("MyParam");)
the output is:

--- Transit2 ---
Trans 1 : Transit N1
Trans 2 : null

why null?

web.xml:


firs servlet - Transit1.java:


second servlet - Transit2.java:
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 2778
174
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

--- Transit2 ---
Trans 1 : Transit N1
Trans 2 : null

why null?

I would expect it to throw a HTTP Status 404 - page not found.

You servlet-mapping shows:
and therefore the code in your Transit1 Servlet should be:

 
Serafim Plishas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank your! in works!
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!