views:

48

answers:

3

I have installed Tomcat 5.0 in order to execute a web application. How can I show my files which are present in Tomcat to the web browser? I tried http://hostname:8080/myfolder/login.html, but I can't see the files.

One more thing I know about JDBC and other database connectivity and I have developed a HTML page. How can I let a button in the page execute the code written in a Servlet and perform validations?

A: 

Tomcat is not a web server like, say, Apache. It's a servlet container. You can not just move file in a subfolder which seem to be what you did. You need to pack your web application in a .war and deploy it.

The URL should rather be http://host:8080/webapp/subfolder/login.jsp

Without much information it's hard to help. Please edit your question and describe what you've done so far.

ewernli
This is not correct. Tomcat will "infer" a webapp from a folder structure, if that's all you give it. It doesn't even need a `web.xml`.
skaffman
The point is that I have the impression the OP is a bit confused about how to develop web app in java and and mentions servlet, html login page, jdbc, validation. Sure you can have "exploded directory" and move certain files. But it looks like he expect "servlet files" to be executed much like Apache/PHP which is why I answered like this. I will anyway no even bother helping next time if I get downvoted in such case.
ewernli
+1  A: 

The simplest thing is to add to the root webapp. That is webapps/ROOT. Any file you put in there will be served unless you change the default configuration.

You should read about the details, of course.

bmargulies
+1  A: 

I have installed Tomcat 5.0 in order to execute a web application.

First of all, why are you using the ancient (8 year old) Tomcat 5.0? If you can, rather grab the latest one, Tomcat 6.0.

How can I show my files which are present in Tomcat to the web browser? I tried http://hostname:8080/myfolder/login.html, but I can't see the files.

Is myfolder the context name or just a folder in your webcontent? If it's a context name, then you need to ensure that it's properly deployed. You can find details in the server logs in the /logs folder. If it is a folder in your webcontent and the webapplication is thus supposedly to be the "root" application, then you need to ensure that it's deployed as ROOT.

To learn more about using Tomcat, go through the documentation.

One more thing I know about JDBC and other database connectivity and I have developed a HTML page. How can I let a button in the page execute the code written in a Servlet and perform validations?

To the point, just create a class which extends HttpServlet, implement the doPost() method, define the servlet in web.xml and let the action attribute of the HTML <form> element point to an URL which is covered by the url-pattern of the servlet mapping in the web.xml.

As the question is pretty broad, I have the impression that you haven't learned in any way how to work with Tomcat and JSP/Servlets. I would strongly recommend to go through those tutorials to familarize yourself with JSP/Servlet on Tomcat and Eclipse (an IDE) first: Beginning and Intermediate-Level Servlet, JSP, and JDBC Tutorials

BalusC