How to run an example servlet? Using- Netbeans7 & Tomcat6, OS=Ubuntu 10.10, linux 2.6
Hi!
I'm learning to use servlets using Netbeans7 and Tomcat6 on a linux machine(Ubuntu 10.10). I have created a user in tomcat with manager,admin,tomcat and role1 roles. I added the Java EE 6 API library in my default project in netbeans and wrote the code for simple "hello world" servlet. Now I have book that suggests copying the compiled .class file to the folder which contains the class files for other default examples and then use it's address as URL in a html file. I found that by default I don't have the permission to do so. That leads me to suspect that this is not the right way of going about it. What is the correct method?
I have configured netbeans to use tomcat and I'm not getting any compilation errors.
Also, are the examples that came with Tomcat different from the sample programs in Netbeans. If yes, how do I run the sample servlets provided in netbeans? Right clicking and selecting "run file" gives
Quote:
FAIL - Application already exists at path /
Re: How to run an example servlet? Using- Netbeans7 & Tomcat6, OS=Ubuntu 10.10, linux
How are you trying to access by a URL? For tomcat this is typically through port 8080, with the path defined by the deployed jar
http://localhost:8080/pathtowar/servlet.jsp (depending upon the web.xml mappings in the war)
I don't use netbeans, so cannot comment on that aspect of your question.
Re: How to run an example servlet? Using- Netbeans7 & Tomcat6, OS=Ubuntu 10.10, linux
Thanks copeg! I don't understand what is meant by "path defined by the deployed jar". How is it determined?
Forget about Netbeans. (Instead of trying to run individual java files, running the sample project works.)
What if I write a servlet code, compile it to a class file anywhere on my disk? How do I invoke it in a HTML file so that tomcat can find it?