Hi, I m new to this JSP, and i have installed Tomcat version 3.3. I got tomcat running and the jsp examples running fine. Now i m trying to run a simple jsp page where i want to display hello world. But i get an error. I saved the helloworld.jsp file in the following ROOT directory: C:\jakarta-tomcat-3.3\webapps\ROOT\helloworld.jsp and i try to run it on the web browser by typing: http://localhost:8080/root/helloworld.jsp
but i get an error file not found. I m pretty new to this,and maybe i m placing it in the wrong directory....or do i need to compile it? ....i m Can anyone help? Suzana
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
posted
0
Create a jsp folder under the webapps\ROOT\ directory and out it there. Access it by including jsp in the path.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
durgesh
Greenhorn
Joined: Oct 16, 2001
Posts: 2
posted
0
hi go to the folder where you have installed tomcat .. usually it is in program files/apache tomcat 4.0/webapps/examples/urfoldername place ur just file in the urfoldername folder and in the broswer type in the following url http://localhost:8080/examples/jsp/urfoldername/select.jsp hopes this helps durgesh
Suzana Shah
Greenhorn
Joined: Jan 07, 2002
Posts: 12
posted
0
Hi, Thanks for the suggestions, i have tried both ways, but for soem reason its not finding the file, every time i get this error on the tomcat server: 2002-01-20 17:46:37 - Ctx() : Status code:404 request:R( + /hello/hello.html + null) msg:null i have tried saving the hello.jsp under a folder called hello and then saved it under the webapps/ROOT directory, as well as doing it the other way such as saving it under webapps/examples/jsp/hello directory and i still get the same error....file not found...is there soemthing else which i m missing...i dont know...i can run the jsp examples fine....by typing as follows: http://localhost:8080/examples/jsp/num/numguess.jsp but when i try running my hello.jsp it cant find it..hellp.......can anyone explain if i m missing something Thanks Suzana
Suzana Shah
Greenhorn
Joined: Jan 07, 2002
Posts: 12
posted
0
hi, i realised something strange, i even tried creating a simple html file and then tried to view it from the browser but it gave me the same error, but when i restarted the tomcat server again during startup i got this message: 2002-01-20 17:55:52 - WorkDirSetup: Creating work dir C:\jakarta-tomcat-3.3\work\DEFAULT\hello 2002-01-20 17:55:52 - ContextManager: Adding DEFAULT:/hello and then when i run the hello.html file from localhost it runs: i type as follows: http://localhost:8080/hello/hello.jsp as i am saving the hello.html under the C:\jakarta-tomcat-3.3\webapps\hello directory and now i can view the html file, but anything other then that gives me the file not found error...even if i put it under the hello directory....whats going on and why does tomcat display such message when starting up? confused and lost..can anyone help...... pleaseeeeee, Suzana
Sals Hamid
Greenhorn
Joined: Jan 04, 2002
Posts: 24
posted
0
Do u set paths for tomcat, if yes then write the following code <%@ page language ="java" %> <% out.println("Hello World"); %> save it in Root in your folder. try to open. first check ur paths are right
No Path of Flowers lead to glory
Arokia Raj
Greenhorn
Joined: Nov 18, 2004
Posts: 1
posted
0
I am unable to run Jsp file using apache tomcat. but the examples given in the apace-tomcat package are running well. Please help me.
Please note that Tomcat is case-sensitive. So if you run http://localhost:8080/hello.jsp (small letter h), it won't work. Since your file is saved as Hello.jsp.
Joyce [ November 19, 2004: Message edited by: Joyce Lee ]
Joyce Lee
Ranch Hand
Joined: Jul 11, 2003
Posts: 1392
posted
0
Continue...(part 2)
Let's say you don't want to place this Hello.jsp under C:\tomcat\webapps\Root directory. You want to create your own directory.
With the Tomcat shutdown, create a new directory called myproject under C:\tomcat\webapps. Place this Hello.jsp under C:\tomcat\webapps\myproject. In order for the Tomcat to recognise this myproject during deployment, you need to create an empty directory web-inf under C:\tomcat\webapps\myproject. Now startup the Tomcat and run this application http://localhost:8080/myproject/Hello.jsp
You might want to take a look at this thread. [ November 19, 2004: Message edited by: Joyce Lee ]
the problem taht am facing si somewhat similar to the current thread. I'm written a jsp (Welcome) calling another one (Login.jsp). Once the login details are furnished in Login.jsp, it transfers control to ValidateServlet. Validateservlet in turn calls a couple of other java user-defined classes.
The problem is as follows: I placed the Welcome.jsp and Login.jsp in the webapps/root folder (Tomcat 5.0.24) I placed the ValidateServlet.java, User.java, DBConnection.java in C:\jakarta-tomcat-5.0.24\webapps\ROOT\WEB-INF\classes folder. If i try to place the servlet details in the web.xml in the corresponding WEB-INF, while running the jsp with the command in IE browse http://localhost:8080/Welcome.jsp
the response is "/Welcome.jsp resource not found"
if i remove the amendments that i did to web.xml, the jsp leads to Login.jsp without any problem, but further fails to locate ValidateServlet.
could ther ebe any problem with Login.jsp calling ValidateServlet. for ur ref. attaching the login.jsp code here.
<Html> <body>
<%@ page language ="java"%> <%@ page import="java.io.*"%> <%@ page import="java.sql.*"%>
<br> USERNAME <input type = "text" name = "loginname" size = "10" > </br> <br> PASSWORD <input type = "password" name = "password" size = "10" > </br> <br><input type = "submit" name = "submit" value = "SUBMIT" > </br>
<% } else {
out.println("Thanks for visiting this page"); }
%>
</form> </body> </html>
sorry for such a verbose explanation, but need help badly.
Thanks, Prasoona.
Joyce Lee
Ranch Hand
Joined: Jul 11, 2003
Posts: 1392
posted
0
Hi Prasoona,
If i try to place the servlet details in the web.xml in the corresponding WEB-INF, while running the jsp with the command in IE browse http://localhost:8080/Welcome.jsp
the response is "/Welcome.jsp resource not found" It could be the servlet details added incorrectly in the web.xml. As a result, the application could not be deployed.
Try to add this in the web.xml. Assuming ValidateServlet.class is in .../WEB-INF/classes directory.
if i remove the amendments that i did to web.xml, the jsp leads to Login.jsp without any problem, but further fails to locate ValidateServlet. ValidateServlet class must be declared in the web.xml using <servlet> element otherwise it cannot be located.
Joyce
Prasoona Rr
Greenhorn
Joined: Nov 25, 2004
Posts: 4
posted
0
Well well, within a few hrs of irritating my pc,I achieved my way. The code is working now. All that I had to do was follow the instructions as in Tomcat installation, specifically the "uncommenting of invoker" in web.xml in conf folder.
But the concept that I dont understand is "why should it not identify the first jsp at all, if i try to map the servlet in the corresponding web.xml file"
Please could anyone clarify this?
Thanks Prasoona.
Joyce Lee
Ranch Hand
Joined: Jul 11, 2003
Posts: 1392
posted
0
Well well, within a few hrs of irritating my pc,I achieved my way. The code is working now. All that I had to do was follow the instructions as in Tomcat installation, specifically the "uncommenting of invoker" in web.xml in conf folder. I didn't uncomment the invoker. That's why I provided the <servlet-mapping> element in the WEB-INF/web.xml.