Running a JSP page on a Tomcat server?

I am new to JSP. I am trying to run a JSP page on a TOMCAT server.

Below are the steps I used.

1). Created the following JSP page to disable the current date.

<%@page contentType="text/html" import="java.util.*" %> <html> <body> <p>&nbsp;</p> <div align="center"> <center> <table border="0" cellpadding="0" cellspacing ="0" width="460" bgcolor="#EEFFCA"> <tr> <td width="100%"><font size="6" color ="#008000">&nbsp;Date Example</font></td> </tr> <tr> <td width="100%"><b>&nbsp;Current Date and time is:&nbsp; <font color="#FF0000"> <%= new java.util.Date() %> </font></b></td> </tr> </table> </center> </div> </body> </html> 

2) Save it with the name Date.jsp in webapps (webapps / JSPSample / date.jsp) in tomcat

3) I also created the WEB-INF folder inside the JSPSample folder. In the WEB_INF folder, I put web.xml with the following code

 <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>JSP test client</display-name> <servlet> <servlet-name>JSP Sample</servlet-name> <display-name>JSP Sample</display-name> <description>no description</description> <jsp-file>/date.jsp</jsp-file> </servlet> <session-config> <session-timeout>30</session-timeout> </session-config> </web-app> 

4) The folder structure looks like

  webapps --JSPSample ----WEB-INF--web.xml ----date.jsp 

5) Later, by opening any Internet browser and typing the following URL

  http://localhost:8080/JSPSample/date.jsp 

When trying to run a JSP file, the following errors are displayed

  org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:156) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.hp.sips.basic.container.impl.servlet.RestFilter.doFilter(RestFilter.java:67) root cause org.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:620) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.hp.sips.basic.container.impl.servlet.RestFilter.doFilter(RestFilter.java:67) root cause java.lang.ClassNotFoundException: org.apache.jsp.UIDesign_jsp java.net.URLClassLoader$1.run(Unknown Source) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(Unknown Source) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66) org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:618) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.hp.sips.basic.container.impl.servlet.RestFilter.doFilter(RestFilter.java:67) 

When you refresh the page below, is also displayed

  exception javax.servlet.ServletException: java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem; org.apache.jasper.servlet.JspServlet.service(JspServlet.java:275) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.hp.sips.basic.container.impl.servlet.RestFilter.doFilter(RestFilter.java:67) root cause java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem; org.apache.jasper.compiler.JDTCompiler$2.acceptResult(JDTCompiler.java:370) org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:429) org.apache.jasper.compiler.Compiler.compile(Compiler.java:334) org.apache.jasper.compiler.Compiler.compile(Compiler.java:312) org.apache.jasper.compiler.Compiler.compile(Compiler.java:299) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.hp.sips.basic.container.impl.servlet.RestFilter.doFilter(RestFilter.java:67) 
+4
source share
2 answers

I just downloaded Tomcat 7 , created the /webapps/JSPSample/date.jsp and /webapps/JSPSample/WEB-INF/web.xml with your content, and it just worked.

This means that the problem is with your environment (installation method of Tomcat, operating system, IDE), and not with Tomcat.

+3
source

I found that the problem with jsp-2.1-6.1.14.jar in WEB-INF / lib is causing the problem.

+1
source

Source: https://habr.com/ru/post/1384293/


All Articles