Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Why is HttpServlet needed on the Java Build Path?
Why is HttpServlet needed on the Java Build Path? [message #1449524] Tue, 21 October 2014 13:44 Go to next message
Peter Palaga is currently offline Peter PalagaFriend
Messages: 2
Registered: October 2014
Junior Member
Hi *,

I basically have a maven project [1] using JSP just for rendering a UI of a portlet. javax.servlet.http.HttpServlet is not necessary at all to either build or run it, but I am getting this error marker on the JSP file anyway:

Quote:
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path


What is triggering the marker? Is my project misconfigured somehow? Or is WTP assuming incorrectly that all JSP files have to be used as servlets?

[1] github com /jboss-developer/jboss-portal-quickstarts/tree/6.2.x-develop/cdi-scopes-portlet - obfuscated a little bit, sorry, I can only use links to eclipse.org sites while I have fewer than 5 messages
Re: Why is HttpServlet needed on the Java Build Path? [message #1450453 is a reply to message #1449524] Wed, 22 October 2014 13:13 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 10/21/2014 11:53 AM, Peter Palaga wrote:
> Hi *,
>
> I basically have a maven project [1] using JSP just for rendering a UI
> of a portlet. javax.servlet.http.HttpServlet is not necessary at all to
> either build or run it, but I am getting this error marker on the JSP
> file anyway:
>
> Quote:
>> The superclass "javax.servlet.http.HttpServlet" was not found on the
>> Java Build Path
>
>
> What is triggering the marker? Is my project misconfigured somehow? Or
> is WTP assuming incorrectly that all JSP files have to be used as servlets?
>
> [1] github com
> /jboss-developer/jboss-portal-quickstarts/tree/6.2.x-develop/cdi-scopes-portlet
> - obfuscated a little bit, sorry, I can only use links to eclipse.org
> sites while I have fewer than 5 messages

Actually, JSPs are servlets. They are just created in a way that
differs from writing Java directly. If you happen to be using Tomcat,
you can examine the Java file created for the JSP under the "work"
folder. You will find that the generated class extends HttpJspBase,
which extends HttpServlet. I don't think any of this impacted by
whether the JSP is accessed from a portlet or from a browser.

WTP expects projects that contain JSPs to have a server runtime
associated with the project. This runtime will correspond to a version
of the Servlet/JSP spec and will designate which servers you can and
can't deploy the project to. If you use Servlet 3.1 or JSP 2.3, for
Tomcat you could only deploy to version 8.0. WTP will also use this
runtime version to guide the editor for JSPs and other appropriate
editors to match the features in that version of the spec. Since none of
this is involved in actually building your project, I'm guessing the
maven configuration isn't bothering to take this into account.

Cheers,
Larry
Re: Why is HttpServlet needed on the Java Build Path? [message #1451240 is a reply to message #1450453] Thu, 23 October 2014 14:30 Go to previous messageGo to next message
Max Rydahl Andersen is currently offline Max Rydahl AndersenFriend
Messages: 233
Registered: July 2009
Senior Member
Larry,

The issue here is that in his project the jsp is not used from a servlet but from a portlet. His jsp has no reference to servlet api's whatsoever as far as I can see.

It seems the assumption wtp has about all .jsp's are servlets are leaking out here.

Can you point me to where in n WTP we are wrapping things in servlet api ? maybe we can filter out errors/warnings that relates to errors on lines of code that does not relate to the actual jsp ?
Re: Why is HttpServlet needed on the Java Build Path? [message #1451310 is a reply to message #1451240] Thu, 23 October 2014 16:44 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 10/23/2014 10:30 AM, Max Rydahl Andersen wrote:
> Larry,
> The issue here is that in his project the jsp is not used from a servlet
> but from a portlet. His jsp has no reference to servlet api's whatsoever
> as far as I can see.

I must be missing something here because I don't see how where a JSP is
"used from" affects the nature of the JSP, i.e. that JSPs are converted
to servlets at runtime. I'm not all that familiar with the details of
Portlet technology. Does Portlet technology have it's own means of
processing JSPs which is different from servlet containers? If so, I
stand corrected. However, I'm doubtful that the JSP handling in WTP is
implemented to make that distinction.

>
> It seems the assumption wtp has about all .jsp's are servlets are
> leaking out here.
>
> Can you point me to where in n WTP we are wrapping things in servlet api
> ? maybe we can filter out errors/warnings that relates to errors on
> lines of code that does not relate to the actual jsp ?
>
Unfortunately, what I'm going on is what I saw debugging a JSP taglib
bug I encountered many years ago. Given how dated that information I'm
working with is and that it was only pieces of the JSP support, I don't
know where to point you.

Cheers,
Larry
Re: Why is HttpServlet needed on the Java Build Path? [message #1451905 is a reply to message #1451310] Fri, 24 October 2014 13:24 Go to previous message
Peter Palaga is currently offline Peter PalagaFriend
Messages: 2
Registered: October 2014
Junior Member
Hi Larry and Max,

> is portlet api 100% independent from servlet?

After having looked properly, yes, Portlet API 2.0 depends on Servlet API 2.4., see

mvnrepository com /artifact/javax.portlet/portlet-api/2.0 *

But given this, should not m2e and WTP all the better know about the missing servlet class as it there in an indirect dependency of my project?

Studying this even deeper I found out that we declare web app 2.5 in the project's web.xml: git.io /ViVHNA *

Could the version mismatch be the problem? I tried to change it to 2.4 but the JSP error has not gone away and I got two new errors "Cannot change version of project facet Dynamic Web Module to 2.4." and "One or more constraints have not been satisfied." I am not sure if these two new errors are issued by WTP.

Thanks,

Peter

* obfuscated because I can only use links to eclipse.org sites while I have fewer than 5 messages
Previous Topic:Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript
Next Topic:JavaScript files with UTF-8 encoding
Goto Forum:
  


Current Time: Fri Apr 19 01:48:34 GMT 2024

Powered by FUDForum. Page generated in 0.01995 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top