On 25/05/2011 18:14, Christopher Schultz wrote: > Kerotan, > > On 5/25/2011 9:32 AM, kerotan wrote: >> On "Package Explorer" of Eclipse, the file system is showed as follows: >> -------------------- >> test >> +--- WEB-INF/src >> | +--- servlets >> | +--- HelloServlet.java >> +--- sample.txt >> -------------------- >> Yes. This webapp is devployes into the /test context path because I >> confirmed the following two points. >> First, I checked that >> \apache-tomcat-7.0.14\conf\Catalina\localhost\test.xml is existed and >> that "<Context path="/test"........../>" is described in test.xml. > > You should not have the "path" attribute set in the <Context>... Tomcat > can infer the name of the context path from the name of the XML config > file, or the name of the WAR (or exploded WAR directory). > >> Second, I tested that /test context path is workable with calling >> "http://localhost:8080/test/sample.txt" on a browser. It is OK. > > Good. > >>>> A different file name, or a different "name" attribute chosen in the >>>> @WebServlet annotation? The former makes no sense, while the latter >>>> makes perfect sense. > >> On "Package Explorer" of Eclipse, the file system is showed as follows: >> -------------------- >> ex3 >> +--- WEB-INF/src >> | +--- input >> | | +--- GuessServlet.java >> | +--- input2 >> | +--- GuessServlet.java >> +--- input >> | +--- guess.jsp >> +--- input2 >> +--- guess.jsp >> -------------------- >> "GuessServlet.java" of input2 package and "guess.jsp" of input2 package >> revise specification of each input package. >> In this case, "@WebServlet" annotation was not available under the >> different "urlPatterns". >> ------------ >> package:input >> file name:GuessServlet.java > >> @WebServlet(name="GuessServlet", urlPatterns={"/guess"}) >> public class GuessServlet extends HttpServlet { >> ------------ >> package:input2 >> file name:GuessServlet.java > >> @WebServlet(name="GuessServlet", urlPatterns={"/guess2"}) >> public class GuessServlet extends HttpServlet { > > > Here, the problem is not that the file/class name is the same, but > because you have declared both servlets to be called "GuessServlet". > That's not legal: you must give them distinct names. > >> I would like to explain a flow of three programs above Eclipse file system. >> First, A browser calls "http://localhost:8080/basic/reqattr/guess.jsp". > > Everything here is confusing: the context path changes from "/test" to > "/ex3" to "/basic". Let's deal with one thing at a time, here. > >> Second, "guess.jsp" calls "/reqattr/GuessServlet.java" by inputing a >> charactor. In this servlet program, depending on a answer, a return path >> is branched into two paths. >> Third, two path are brabched depending on a answer. One is >> "/reqattr/guess.jsp". Another is "/reqattr/guess_hit.jsp". The branch >> control is done by "RequestDispatcher dispatcher = >> request.getRequestDispatcher(path);". >> Forth, "GuessServlet.java" can return to "guess.jsp" or "guess_hit.jsp". >> Fifth, "guess.jsp" can call "/reqattr/GuessServlet.java" by inputing a >> charactor, again. >> Sixth, Here, a browser showed the error message of HTTP status 404, >> which indicated that the requested resource(/guess) is not available. > > - From what you have above, "/guess" does not appear to be a valid URL. > You appear to have lost the context path somewhere. > >> A program of file upload with "@WebServlet" and "@MultipartConfig" is >> successfully workable in my environment. So far, I would like to ask you >> a technique to follow the specification of Servlet 3.0. Or is Tomcat >> 7.0.14 under the implementation of the specification on Servlet 3.0? > > Yes, Tomcat 7.0 follows Servlet 3.0. You just appear to be using it > incorrectly.
Not to mention trying to get Tomcat to execute .java files that have no been compiled into .class files. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org