I am having a problem making the call getContextPath() on a HttpRequest object in a servlet? Any suggestions or comments why it is happening?
Appreciate the help. Hari -----Original Message----- From: Varley, Roger [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 20, 2002 10:40 AM To: [EMAIL PROTECTED] Subject: Re: Your Message Sent on Tue, 19 Mar 2002 15:35:33 -0000 > > > You can only go back to the root of your project when using > getResource > > For the servlet 2.3 specs: > > "The getResource and getResourceAsStream methods take > a String with > a > leading "/" as argument which gives the path of the resource > relative to the root of > the context. This hierarchy of documents may exist in > the server's > file system, in a > web application archive file, on a remote server, or > at some other > location." > > As you can see beginning with the / is a requirement. > > for mine, i use getServletContext().getResource("/flow.xml"); > This refers to the /flow.xml in my root directory. > If your Register1.asp is not in the root directory or its > subfolders then > you need to move it. Hi, Thanks for your response. I've tried that and moved the register1.asp file. The code now looks like; ServletContext sc = config.getServletContext(); url = sc.getResource("/register1.asp"); System.out.println(url.toString()); I must be missing something obvious though because now the problem is that getResource() is returning a file:// url not an Http url so when I try to open the connection, the servlet crunches again. The system prints the content of the URL as file:e:\tomcat\webapps\Application\register1.asp. I need an HTTP connection. Regards Roger ************************************************************************ Information in this message is confidential and may be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please notify the sender and delete the message immediately. Unauthorised disclosure, distribution and copying of this email is strictly prohibited. The opinions expressed within this message are those of the individual author. Whilst Brake Bros takes reasonable steps to scan this email it does not accept liability for any virus that may be contained in it. Bros Foodservice Limited, Enterprise House, Eureka Business Park, Ashford, Kent TN25 4AG. Registered in England and Wales number 706764. Telephone 01233 206000 Fax 01233 206006. ___________________________________________________________________________ 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 ___________________________________________________________________________ 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
