0

I am trying to get eclipse neon EE ready for making a JSP/Servlet dynamic web project but it just won't cooperate with me.

this is day 3, i read many manuals and searched online and managed to get it working to a certain extent, but I am stumped now and so much time is lost yet i still haven't even started working on the project!

What I am using is:

  • Tomcat v8.0.
  • Jre jre1.8.0_101
  • Eclipse Java EE IDE for Web Developers (Neon.1 Release (4.6.1) )

now the main problem is that the server won't recognize the Servlets, it also would not accept class calls from within JSP files.

The IDE shows that there is a Servlet and the Servlet mapping in the deployment descriptor but it would still give me a 404 error, i checked inisde the WEB-INF and there was no web.xml file so i created it and set the mapping manually yet to no avail.

 <servlet>
    <servlet-name>ShowText</servlet-name>
    <servlet-class>test.ShowText</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ShowText</servlet-name>
    <url-pattern>.ShowText</url-pattern>
</servlet-mapping>

Error:

HTTP Status 404 - /sem6/Tomcat-8.0/webapps/sem6/.ShowText
type Status report

message /sem6/Tomcat-8.0/webapps/sem6/.ShowText

description The requested resource is not available.

--------------------------------------------------------------------------------

Apache Tomcat/8.0.37

As for class calls when i call it inside the IDE it recognizes it and auto-completes it and shows no errors, yet the JSP page shows me an error:

An error occurred at line: 4 in the jsp file: /Tomcat-8.0/webapps/sem6/index.jsp
Constants cannot be resolved to a type
1: 
2: <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3:     pageEncoding="ISO-8859-1" import="base.Constants" %>
4: <%! Constants c = new Constants();  %>
5: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
6: <html>
7: <head>


An error occurred at line: 4 in the jsp file: /Tomcat-8.0/webapps/sem6/index.jsp
Constants cannot be resolved to a type
1: 
2: <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3:     pageEncoding="ISO-8859-1" import="base.Constants" %>
4: <%! Constants c = new Constants();  %>
5: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
6: <html>
7: <head>


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.37 logs.

What is wrong here? why is it doing this?I couldn't get it working at all!

Is there a step by step easy configuration that i can follow for an easy set up?

i want a full integration of the server and the IDE, the IDE still creates the server configuration in a folder in the workspace which bothers me.. but it only contains server configurations

bakz
  • 79
  • 15
  • My experience with the eclipse built in servers is neither satisfying. Therefore I refrained using it I am using eclipse just for developing the code, let a build script create the deliverable, running the server in a separate process (even in a own VM) and using remote debugging in order to step through the code in eclipse. This approach I find much more productive and nearer to the real deployment process. – Heri Oct 09 '16 at 18:07
  • @Heri That's what I wanted to do at first, but i really have no clue how to set it up in that way! if i can just compile it and it auto deploys it to the server then that is more than enough for me, having to manually copy the classes and redeploying the application every time there is a change makes life so much harder, mind telling me the best way to set it up this way please? – bakz Oct 09 '16 at 18:11
  • Where does `base.Constants` come from? If it's in a jar file, is it being deployed to the server properly? What URL are you navigating to to reproduce this? – nitind Oct 20 '16 at 05:23

1 Answers1

1

Where did the Constants comes from? you need to write import statement in jsp if you want to use any java class in JSP.

See the post below - How do you import classes in JSP?

As the error says that

Constants cannot be resolved to a type

I am damn sure that your full classpath for Constants.java is wrong.

Community
  • 1
  • 1
Chirag Parmar
  • 833
  • 11
  • 26