2
votes

I am midway developing my first dynamic web project in eclipse. I am using tomcat v7. I have developed a login.jsp page. On success, it redirects to another home.jsp.

It worked well in eclipse. I edited the web.xml file by changing index.jsp to login.jsp. Both the jsp files are in WebContent folder. Also, i have included a servlet.java file in the jsp file. the servlet file resides in projectName/resources/src/pkg folder.

But when I pasted the project folder as a whole into the Apache/webapps folder, and tried to run the project from browser (after starting tomcat) using localhost:8080/ProjectName/ it returned error 404.

When i tried using localhost:8080/ProjectName/WebContent/login.jsp , then the jsp file was loaded. But on entering the correct username and password, it didnt redirect to home.jsp.

Can anyone please help me.. Thanks in advance.

3
YOu need to export the project as a war. File-> Export -> warPatton
@Patton It is not a necessity to use WAR archive. It can be a usual project folder, just the project directory structure must be correct.informatik01

3 Answers

3
votes

Don't paste the whole project, you must export it as a WAR file and then copy it to the Tomcat 's webapp folder.

2
votes

Package the application as a WAR file and put it in Tomcat's webapps directory.

Tomcat will automatically deploy the application on startup.

You cannot simply drop an Eclipse project directory in to Tomcat since Eclipse projects won't generally follow the Java EE webapp directory structure. Eclipse creates/moves the artifacts to appropriate locations during the development process "behind the scenes" so everything works.

0
votes

It is most important question in interview for experienced candidates.

We can auto deploy the java source code in tomcat by using the following file example.

Location: E:\Tomcat6.0\conf\Catalina\localhost\DMS.xml.

From this file we need to do our configurations in DMS.xml file.

Here DMS is my project name.

Example

Context antiJARLocking="true" docBase="E:\DMS\build\web" path="/DMS"