I have a JSP file named aniltest.jsp
which has following code:
<%
try {
URL aURL = new URL("http://localhost:80/admin/anil1.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(aURL.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println("content of anil1.txt: " + inputLine);
in.close();
} catch (IOException e) {
System.out.println("Error reading content of url");
e.printStackTrace();
}
%>
In the above code I am trying to read a text file named anil1.txt
which is located at http://localhost:80/admin/anil1.txt
I get below error when I run: http://localhost:80/aniltest.jsp
java.io.FileNotFoundException: http://localhost:80/admin/anil1.txt at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625) at _jsp._aniltest__jsp._jspService(_aniltest__jsp.java:93) at _jsp._aniltest__jsp._jspService(_aniltest__jsp.java:31) at com.caucho.jsp.JavaPage.service(JavaPage.java:64) at com.caucho.jsp.Page.pageservice(Page.java:548) at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:194) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:156) at com.caucho.server.webapp.AccessLogFilterChain.doFilter(AccessLogFilterChain.java:95) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:289) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:838) at com.caucho.network.listen.TcpSocketLink.dispatchRequest(TcpSocketLink.java:1349) at com.caucho.network.listen.TcpSocketLink.handleRequest(TcpSocketLink.java:1305) at com.caucho.network.listen.TcpSocketLink.handleRequestsImpl(TcpSocketLink.java:1289) at com.caucho.network.listen.TcpSocketLink.handleRequests(TcpSocketLink.java:1197) at com.caucho.network.listen.TcpSocketLink.handleAcceptTaskImpl(TcpSocketLink.java:993) at com.caucho.network.listen.ConnectionTask.runThread(ConnectionTask.java:117) at com.caucho.network.listen.ConnectionTask.run(ConnectionTask.java:93) at com.caucho.network.listen.SocketLinkThreadLauncher.handleTasks(SocketLinkThreadLauncher.java:169) at com.caucho.network.listen.TcpSocketAcceptThread.run(TcpSocketAcceptThread.java:61) at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173) at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118)
Though I can access the file http://localhost:80/admin/anil1.txt
in the web browser without any problem: I am using latest Resin server. I am totally stuck and can't figure it out what is the problem.