Java project. Problem with JspWriter

17,320

Solution 1

The import javax.servlet.jsp.JspWriter cannot be resolved

In case of Tomcat, it's part of jsp-api.jar file. However, do not manually add this file to the buildpath like as you did for servlet-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.


I looked at Java Build Path and I have following:

1) servlet-api.jar - C:\Program Files...

Remove this one. It'll only collide with any target runtime which you're going to configure soon.


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.

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:

Solution 2

javax.servlet.jsp.JspWriter will not present in servlet-api.jar of your Tomcat distribution. Rather, it is usually present in the jsp-api.jar file.

You should rebind the Apache Tomcat 6 Server Runtime, back into your project's classpath, so that all the JARs provided by Tomcat 6 are made available once again. An unbound Tomcat 6 Server Runtime serves no purpose other than to inform you that you've copied an Eclipse project whose classpath entries were or might have been valid in the original Eclipse workspace.

To reintroduce the Apache Tomcat 6 Server into your project's classpath, first define the Server Runtime in Eclipse, using your existing Tomcat 6 installation. Later, add the Server Runtime as a library in your project's build path.

Share:
17,320
bobetko
Author by

bobetko

Updated on June 22, 2022

Comments

  • bobetko
    bobetko almost 2 years

    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.