Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

tomcat uri map  RSS feed

 
zhebincong
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please see my code:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Home.java
package com.mansion;
import java.util.*;
import java.io.*;
public class Home{
public String getHome() throws Exception{
Properties p=new Properties();
FileInputStream fis=new FileInputStream("propfile.txt");
p.load(fis);
String home=(String)p.get("HOME");
return home;
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//TestHome.java
package com;
import com.mansion.*;
public class TestHome{
public static void main(String[] argv){
Home home=new Home();
try{
System.out.println(home.getHome());
}catch(Exception e){
System.out.println(e.getMessage());
}
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//TestHomeServlet.java
import javax.servlet.*;
import com.mansion.Home;
import java.io.*;
import javax.servlet.http.*;
public class TestHomeServlet extends HttpServlet{
public void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws IOException,ServletException{
try{
Home home=new Home();
System.out.println(home.getHome());
}catch(Exception e){
System.out.println(e.getMessage());
}
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
i put my files under the path as:
C:\jakarta-tomcat-4.0\webapps\ee\WEB-INF\classes\TestHomeServlet.class
C:\jakarta-tomcat-4.0\webapps\ee\WEB-INF\classes\com\TestHome.class
C:\jakarta-tomcat-4.0\webapps\ee\WEB-INF\classes\com\mansion\Home.class
C:\jakarta-tomcat-4.0\webapps\ee\WEB-INF\classes\propfile.txt
what i mean is to test the "Home.class" by "TestHome.class" and "TestHomeServlet.class" seprately(the "Home.class" use the "java.util.Properties" class to read a text file-"propfile.txt"),when i run the TestHome class in the dos windows,it works well,but when i start my tomcat4,and in the browser,i input "http://127.0.0.1:8080/ee/servlet/TestHomeServlet",the servlet tell me that the system can't find the file "propfile.txt",it seem like that i haven't configured the uri path of tomcat4 correctly,i have tried to put the "propfile.txt" file anywhere under the "....\ee\",they neither work,why?
thank you very much!
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"zhebincong"
Your name doesn't agree with the javaranch guidelines. Please take a moment and re-register after reviewing the guidelines at http://www.javaranch.com/name.jsp
thanks for your cooperation.
- satya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!