Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

web.xml  RSS feed

 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the help of web.xml in web-inf directory is it possible to specify a default file read write delete location independent of using Tomcat or Serveltexec or Jrun.
I need this for servlet/jsp to write/read xml,xsl files.
Regards
Balaji
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I in the blacklist or something,why no one is replying to me ??
Regards
Balaji
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If i write a file in servlet using Tomcat its creating the file at tomcat\bin directory.
Using ServletExec its creating the file at c:\winnt\system32 directory


Is it possible to make it at single location using either web.xml or servlet init parameters.

Regards
Balaji
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I in the blacklist or something,why no one is replying to me ??
I don't think it's personal. I think a lot of people just didn't understand your question, and hoped someone else would answer it. Your second explanation seems clearer, so I'll have a stab at it.
If i write a file in servlet using Tomcat its creating the file at tomcat\bin directory.
Using ServletExec its creating the file at c:\winnt\system32 directory. Is it possible to make it at single location using either web.xml or servlet init parameters.

There is no requirement in the servlet specification for a container to set the "current directory" for file access to anything in particular. However, there are two ways round this.
If all you need is somewhere to put "temporary files", the the container must provide some sort of writable temporary directory, and put a File object for it in the "javax.servlet.context.tempdir" context attribute.
If you need something more permanent, you will need to configure it using some sort of init parameter. In your web.xml file you could put something like:

The you can create a "workdir" File object to represent this directory using comething like:

Has this helped ?
[/code]
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Frank it helped and worked for me!
Now i have decided to use request.getContextPath() than hardcoding at c:\data.
Sorry i was so upset trying this,thats why i wrote like that,also i'm switching from Tomcat to Serveltexec,got lost on many things.
Now I'm okay.
Thanks again.
Regards
Balaji
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!