Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 03:32 PM
Member
 
Join Date: Jul 2007
Posts: 3
Gnanam is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-31-2007, 04:01 PM
Member
 
Join Date: Jul 2007
Posts: 72
Swamipsn is on a distinguished road
Check your struts-config.xml make sure you give all the data source names on that including user.xml
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-31-2007, 04:57 PM
Member
 
Join Date: Jul 2007
Posts: 3
Gnanam is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-31-2007, 05:08 PM
Member
 
Join Date: Jul 2007
Posts: 72
Swamipsn is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-31-2007, 05:30 PM
Member
 
Join Date: Jul 2007
Posts: 3
Gnanam is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-31-2007, 06:22 PM
Member
 
Join Date: Jul 2007
Posts: 72
Swamipsn is on a distinguished road
Actually its automatically load it. If any problem to do it download and use Struts consol third party Struts tool
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write onto a file mirage_87 New To Java 4 10-22-2008 11:19 AM
Regular expression for file path ravian New To Java 3 01-25-2008 10:24 PM
File Write Error vikain Advanced Java 5 01-02-2008 06:38 AM
Write unicode into file vata2999 New To Java 1 08-08-2007 05:04 PM
Help with write file in java mathias New To Java 1 07-31-2007 08:51 PM


All times are GMT +3. The time now is 10:53 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org