Results 1 to 6 of 6
- 07-31-2007, 01:32 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 3
- Rep Power
- 0
to find the workspace path at runtime to write the file
Hi All,
this is my first post in this forum..
I have a Struts project deployed in tomcat webapps. User Sign in details are configured in a xml file and are validated by reading the xml file..The xml file is in the path WEB-INF/classes/com/files/user.xml...
when a new user has to be added his/her details has to be written in the same user.xml file..I read the the file using
getClass().getClassLoader().getResourceAsStream("c om/files/user.xml");
To write the file using filewriter if I have to give the full path without hardcoding it.
For eg.
D:/SDE3.0/workspace/project/WebContent/WEB-INF/classes/com/files/user.xml
when I tried to get this path URL using getClass().getClassLoader().getResource("com/files/user.xml") , i get
C:/Program Files/SDE3.0/tomcat-5.5.16/webapps/Request/WEB-INF/classes/com/files/user.xml
Please suggest me how to solve this issue or is there way to find the workspace path at runtime so that I can avoid hardcoding of this path.
Thanks in advance
Regards,
Gnanam
- 07-31-2007, 02:01 PM #2
Member
- Join Date
- Jul 2007
- Posts
- 74
- Rep Power
- 0
Check your struts-config.xml make sure you give all the data source names on that including user.xml
- 07-31-2007, 02:57 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 3
- Rep Power
- 0
Hi
Thanks for your reply.I am new to struts.This is my first Struts project.
I haven't made any entry for data source in struts-config.xml.
Could you please tell me if I have to use like this
<data-source key="dataSource">
<set-property property="user.xml" value="C:/Program Files/SDE3.0/tomcat-5.5.16/webapps/Request/WEB-INF/classes/com/files/user.xml" />
or
<data-source key="dataSource">
<set-property property="user.xml" value="D:/SDE3.0/workspace/project/WebContent/WEB-INF/classes/com/files/user.xml" />
Pls reply me and pardon me if my question is so lame.
Thanks in advance
Gnanam
- 07-31-2007, 03:08 PM #4
Member
- Join Date
- Jul 2007
- Posts
- 74
- Rep Power
- 0
For make it simple please keep the user.xml file in web-inf directory. And let me to know the IDE you have been use.
- 07-31-2007, 03:30 PM #5
Member
- Join Date
- Jul 2007
- Posts
- 3
- Rep Power
- 0
I am using SDE3.1(Eclipse)
Ok I ll keep user.xml in web-inf dir.
But will getClass().getClassLoader().getResourceAsStream("u ser.xml") load it or will it look in web-inf /classes dir.
- 07-31-2007, 04:22 PM #6
Member
- Join Date
- Jul 2007
- Posts
- 74
- Rep Power
- 0
Similar Threads
-
how to write onto a file
By mirage_87 in forum New To JavaReplies: 6Last Post: 09-08-2009, 03:54 PM -
Regular expression for file path
By ravian in forum New To JavaReplies: 3Last Post: 01-25-2008, 08:24 PM -
File Write Error
By vikain in forum Advanced JavaReplies: 5Last Post: 01-02-2008, 04:38 AM -
Write unicode into file
By vata2999 in forum New To JavaReplies: 1Last Post: 08-08-2007, 03:04 PM -
Help with write file in java
By mathias in forum New To JavaReplies: 1Last Post: 07-31-2007, 06:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks