1

I have made an app using Tomcat as my server. It uses JSP pages and java servlets.

If I copy my webapp (the folder) to some other server, will it run? What are the requirements for it to work/not work?

EDIT: Thanks for the answers. One more thing, what if some of my code uses filepath, that originates from the bin folder of Tomcat. For eg: "../webapps/MyApp/WEB-INF/sample.txt" Is the directory structure the same in all servers?

JeeGurg
  • 105
  • 1
  • 6
  • You need to read the servlet specification very carefully. It describes exactly how this is to be done. – Thorbjørn Ravn Andersen Jul 11 '14 at 11:38
  • Do not add additional questions to your original question. Ask them as new questions. – Raedwald Jul 11 '14 at 16:49
  • But as for your additional question, note that questions like it have been asked many times before. See for example http://stackoverflow.com/questions/4538817/beginner-servlet-question-accessing-files-in-a-war-which-path – Raedwald Jul 11 '14 at 16:53
  • And for your second quextion, also see http://stackoverflow.com/questions/14005749/best-practices-to-store-and-access-resource-files-in-java-web-application – Raedwald Jul 11 '14 at 17:03

2 Answers2

1

Java servlets and JSP are intended to be portable technologies. There is a servlet standard and a JSP standard. Any servlet container (such as Tomcat) that implements the version of the standard that your code uses should be able to run your code.

You should move your web application around by copying its web application archive (WAR) file, rather thsn the directory (the extracted content of the WAR).

Raedwald
  • 46,613
  • 43
  • 151
  • 237
0

Ofcourse it will run , there are many servers out there that support jsp/servlet . Most of them are free for development and some are paid for deployment. See this link for more info

For most of the containers (i am not sure for all but most of them) like Tomcat, Jetty, Resin etc, you don't need to modify the project. You can place your project war file in the webapps directory and the project will get deployed on starting the server.

Mustafa sabir
  • 4,130
  • 1
  • 19
  • 28