• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Path as initialization parameter value

 
Vladimir Kositsky
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
It is repost of my question
I can't initialize parameter value set in web.xml file as following
<web-app>
<servlet>
<servlet-name>List Manager</servlet-name>
<servlet-class>ListManagerServlet</servlet-class>
<init-param>
<param-name>addressfile</param-name>
<param-value>/temp/address.ser</param-value>
////<param-value>C:\temp\address.ser</param-value>doesn't work
</init-param>
</servlet>
</web-app>
source http://novocode.de/doc/servlet-essentials/chapter2b.html
to check proper functionality of servlet i restarted Tomcat and browser
everytime.
it works when i assign address like:
filename = "C:address.ser";
instead of
filename = config.getInitParameter("addressfile");
Any advise will be highly appreciated
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like it should work. What exactly happens when the init method executes this line:
filename = config.getInitParameter("addressfile");
is filename null or do you get an exception?
Also, how are you addressing the servlet in the URL, as ListManager or as ListManagerServlet? You must use the alias in order to get Tomcat to use the init-param
Bill
 
Vladimir Kositsky
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a message:
Error: 503
Location: /servlet/ListManager
Error reading address file: java.io.StreamCorruptedException: Caught EOFException while
reading the stream header
Service is permanently unavailable

BTW, i enjoyed your "Cram" book while did certification
Thanks for reply

 
Vladimir Kositsky
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, it works.
I did unproper creation of empty file prior to running servlet,
that was coused exception
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic