Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deploy servlet

 
Popescu Gabi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'll start by saying that i'm pretty new to servlets.
I just finished my first servlet, using netbeans. But how can i deploy it now? If i right click on the project and press deploy, from what i see it just creates a .war file, but i don't know how to use it. I mean, i don't want to start netbeans in order to use the servlet, i want something like double click and the servlet is online. I use Apache, if it's relevant.
Can you help me, please? Sorry for my beginner question.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can copy the generated war file into the your server. [=
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Ranch,

As you figure out yourself that this is beginner question, then I suggest to use search utility within the forum
as same type of question have been discussed many times here.

and No Need To Say Sorry.
 
Tim Moores
Bartender
Posts: 2803
41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apache is a web server, but what you need is a servlet container - Tomcat is a popular choice.
 
Popescu Gabi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answers, i installed Tomcat 7, i copied the war file to the webapps folder and tomcat extracted the war file. But now i try to access the servlet, it should be on http://localhost:8084/ (that's how it is using Netbeans), but Mozilla says unable to connect (i tried with IE and Opera and it's the same). If i run it inside Netbeans, it works. If i access http://localhost:8080, it finds Tomcat, so Tomcat should be working properly. Am i doing something wrong?
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am i doing something wrong?


You are just hitting the browser with wrong port. you are accessing your server with 8084, while its running over 8080.
 
Haina Minawa
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Popescu Gabi wrote:http://localhost:8084/



The URL for servlet is wrong, it should look like this: http://localhost:8084/WebApp/MyServlet

You have to specify your web application name after port number, then slash, then your serlvet name.
 
Popescu Gabi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, thanks for the answers.
I accessed:
http://localhost:8080/ServletApp/
The application starts, but when it needs to open another page (it should be called
http://localhost:8080/servlet/TableView
it says
HTTP Status 404 - /servlet/TableView
The requested resource (/servlet/TableView) is not available.
I found on the web that it should be because the web.xml is not configured well, but considering it works with netbeans, i'm not sure.
My web.xml looks like this:

 
Popescu Gabi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application was called WebApp and initially it didn't start a servlet, it was starting a simple html page, that's why the url looked like that. After some thinking, i realised the problem was with my forms, with the action attribute, it didn't contained the name of the app. Now i modified it, i'm sure it will work but for the moment i have some difficulties with the cache of the browser, i think, because i modified the code, but when i run the app the source looks the same. Anyway, i'm sure i'll be able to solve this on my own.
Thank you again for all your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic