1

I am building a webapplication project that runs on Tomcat web server. Now I think we will be using Glassfish server in my build webapp. Do I only need to replace the servlet.api of my jsp project to a servlet.api of a Glassfish server?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
PeterJohn
  • 589
  • 3
  • 8
  • 15
  • 1
    Apache is a big software company with many many products such as HTTPD and Tomcat. Please do not say "Apache" while you really meant "Tomcat". You also don't say "Sun" or "Oracle" when you say "Java", "JSP", "Servlet" or "Glassfish". – BalusC Feb 06 '13 at 13:14

2 Answers2

0

You should in first place not have a servlet API JAR file in your webapp project at all. Get rid of all container-specific JAR files in your webapp project. This way your webapp is fully portable across all containers, exactly as intented by Java EE specification.

Having container-specific libraries in the webapp project is a quite common starter's mistake in a careless attempt to "fix" compilation errors on javax.servlet.* classes they face in their Eclipse/Netbeans IDE. This should in first place have been solved differently.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • But Im almost done with my project. In very start I already place my servlet.api in my libraries that come in apache tomcat...What are the procedure I need to make when changing my webserver to glassfish? – PeterJohn Feb 06 '13 at 17:43
  • I'm not sure how that's a hard task. Just delete all copies of Tomcat-specific JARs in `/WEB-INF/lib` folder. They do not belong there. Do you understand the cause and the solution in any way? – BalusC Feb 06 '13 at 17:45
0

Before migrating your project from Tomcat to Glassfish, it is very important to create web.xml in Configuration Files folder. So, create new Servlet in main package. Netbeans(in my case) can generate web.xml Configuration Files folder. Then copy all files from Tomcat server project to Glassfish server project. Then, write all servlet information in web.xml.

If you cannot follow this step, they Definitely, you can face the problem like 404 Page not found error once you executed your final Web application.

Best of Luck !!!!!