Somebody will tell u how to do this with servletContext
I have forget how to do this with context.
when i need to read a xml file,this mathod will be invoked:

InputStream is = Thread.currentThread().getContextClassLoader()
                            .getResourceAsStream("usersearch.xml");

just put ur xml file to CLASSPATH it'll be read by this method.
>Hi Guys,
>
>  I am facing one problem : I am using Tomcat, in my JSP page when i tried
>to read a file say usersearch.xml like below
>
>  File file = new
>File("u:/karthikeyan/karthik/datewatch/xml/usersearch.xml");
>  FileReader reader = new FileReader(file);
>
>  I am not getting any problem but when i tried to give relative path i am
>getting 404 error in my jsp file.  This i need it because when i am going to
>upload to my server online i might not know the full path.
>
>  File file = new File("/samples/xml/usersearch.xml");
>  FileReader reader = new FileReader(file);
>
>  samples - here samples is context name.
>  xml - is the root folder name
>  Here's the context info in the server.xml file
>
>  ---------------------------------
>        <Context path="/samples"
>                 docBase="u:/karthikeyan/karthik/datewatch"
>                 crossContext="false"
>                 debug="0"
>                 reloadable="true" >
>        </Context>
>  -----------------------------------
>
>  I also tried this in desparate mesures
>
>  File file = new File("../xml/usersearch.xml");
>
>  But i am getting the same 404 error
>
>  You guys have any solution to this problem.
>
>  Waiting for yours earliest reply,
>
>  With Regards,
>
>b.karthikeyan.
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
��칻�&ޱ��zf���%��lz��j���w(��݊w%�ע��^n�r��azg����('���K2
LDDI0+r�z�m���j�!�����ڲ�ܢoڭ�b��?����b�׫z�a�iQz�.�Ǭ��i��ڽ�.��&���v�-����^������jZ޲��q�!�iK!$�GzZa���
0����&�f���l�����z�m�

Reply via email to