I got some old JSP web project at work that I am trying to import into eclipse. My experience with java and eclipse is far from great.
In one of the jsp files I am having error:
The import javax.servlet.jsp.JspWriter cannot be resolved
The code:
<%@ page import="org.apache.axiom.om.OMAbstractFactory,
org.apache.axiom.om.OMElement,
org.apache.axiom.om.OMFactory,
org.apache.axiom.om.OMNamespace,
org.apache.axis2.AxisFault,
org.apache.axis2.Constants,
org.apache.axis2.addressing.EndpointReference,
org.apache.axis2.client.Options,
org.apache.axis2.client.ServiceClient,
org.apache.axis2.context.ConfigurationContext,
org.apache.axis2.context.ConfigurationContextFactory,
javax.servlet.ServletContext,
javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse,
javax.servlet.jsp.JspWriter, <- Problem is HERE
javax.xml.parsers.SAXParser,
javax.xml.parsers.SAXParserFactory"
session="false" %>
And, of course, on any other place where I have reference to JspWriter I get same error.
I looked at Java Build Path and I have following:
1) servlet-api.jar – C:\Program Files…
2) Ear Libraries
3) JRE System Library (jdk1.6.0_25)
4) Web App Libraries
I used to have one item for Apache Tomcat 6.0 library which was unbound so I removed it. I tried to add it but couldn’t. When I click Add Library > Server Runtime I get new window says: “Select a runtime to add to the classpath”, but there is nothing to select.
I have installed: Eclipse Java EE IDE for Web Developers, Apache Tomcat installed (6.0), latest version of Ant and Windows 7 64bit.
Any ideas?
Thanks.
In case of Tomcat, it’s part of
jsp-api.jarfile. However, do not manually add this file to the buildpath like as you did forservlet-api.jar, that would not be the right way! It would make your webapp unportable to other target runtimes (read: servletcontainers). I.e. your webapp would be compatible with Tomcat 6.0 only, but not with other container makes/versions like Tomcat 7, Glassfish, JBoss AS, etc.Remove this one. It’ll only collide with any target runtime which you’re going to configure soon.
Go to Servers view in Eclipse. Rightclick it and choose New. Pick the appropriate servletcontainer make and version and walk through the wizard. Now you’ve a target runtime in Eclipse.
Then, in the project’s properties, go to Targeted Runtimes and select the server in there. Nothing else needs to be done. Eclipse will take care of the remaining magic.
See also: