Re: Struts / tomcat 5.5 / File problem



Check out the package java.net.URLEncoder for URL encoding/decoding. You
could also reference the file as a relative path from your webroot. I would
recommend this approach for an actual production environment because you
should never use an absolute path. With an absolute path, that path must be
on any server you deploy your webapp on.

--
Tom Dyess
OraclePower.com

"Tom Vercauteren via JavaKB.com" <forum@xxxxxxxxxxxxxxxxx> wrote in message
news:f3bb1a19db334489a84cf93e949c3be7@xxxxxxxxxxxxx
> Hello,
>
> I'm just starting with struts, with the book : Struts in action.
>
> I use some classes from this book, and in one of them, there is a problem
> in my environment. (jdk 1.4.2_08, tomcat 5.5.9, struts 1.0.2)
>
> The application is a simple registerpage, where a user must give in a
> name,
> and twice the same password. The name & pw will be stored in a
> propertiesfile on the server.
>
> In one of the classes, we gone get the path to the propertiesfile with
> following code :
>
> String file = this.getClass().getClassLoader().getResource
> (UserDirectoryFile).getFile();
> outputstream = new FileOutputStream(o);
>
> But this isn't working.
> The value of file is : "C:/Program%20Files/Apache%20Software%
> 20Foundation/Tomcat%205.5/webapps/register/WEB-
> INF/classes/resources/users.properties"
>
> When i do : file = file.replaceAll("%20", " ");
> Then my code works.
>
> Isn't there any other solution to this problem? (where my code can
> understand %20 as spaces?)
>
> Thanks in advance,
> Tom
>
> --
> Message posted via JavaKB.com
> http://www.javakb.com/Uwe/Forums.aspx/java-general/200505/1


.



Relevant Pages

  • Re: Socket communication on Win32 vs Linux
    ... "Tom Dyess" wrote in message ... > I created a newsgroup reader object that communicates with a newsgroup ... > server and caches articles. ... > the problem is with the rawAuthenticate() method. ...
    (comp.lang.java.programmer)
  • Re: New network setup suggestions needed
    ... > Windows XP for the new server and use it as a file server, ... > web pages and struts app). ... > It is also used for backups and as a file server. ...
    (microsoft.public.windows.server.setup)
  • Re: Help needed with .js and AJAX
    ... > I am using jboss and struts to server up these pages would that have an ... Dag. ... Prev by Date: ...
    (comp.lang.javascript)
  • Re: JSP Encoding
    ... JSP Seite mit dem Formular: ... Dann würde ich mir die response vom server mal genau anschauen, also welches charset im header steht und überprüfen ob der Inhalt stimmt. ... Wenn alles funktioniert weisst du das das Problem mit Struts zu tun hat und kannst gezielt danach suchen. ...
    (de.comp.lang.java)
  • Struts / tomcat 5.5 / File problem
    ... I'm just starting with struts, with the book: ... propertiesfile on the server. ... String file = this.getClass.getClassLoader.getResource ... outputstream = new FileOutputStream; ...
    (comp.lang.java.programmer)