Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Eclipse Web Tools Platform Project (WTP) » JSTL not working in maven(JSTL not working in maven)
JSTL not working in maven [message #1836300] Mon, 28 December 2020 17:51 Go to next message
Jim Whitaker is currently offline Jim WhitakerFriend
Messages: 26
Registered: October 2020
Junior Member
No problem with servlet, but jstl is not working in a maven web project in eclipse.

I did the same servlet and jsp page in netbeans 12.2 chose maven wep project, so same exact code no difference works in netbeans, same tomcat server also.

And I tried many suggestions from stackoverflow post, I mean at least 15 stackoverflow post.

I even tried to add the tag libraries as "add external jars". did the "pom" thing like stackoverflow showed, etc.

Why doesn't jstl work? Must be an on going problem as there are many questions about it on the web.

I have done many "ant" projects in the past in eclipse and never encountered such a thing. The dynamic web projects just always worked. Never needed this forum til now trying to learn maven.

[Updated on: Mon, 28 December 2020 17:52]

Report message to a moderator

Re: JSTL not working in maven [message #1836318 is a reply to message #1836300] Tue, 29 December 2020 00:28 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4438
Registered: July 2009
Senior Member

Don't add it as an external jar--those don't get published to the server because they're not located in your project. Put the jar into your project's WEB-INF/lib folder.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: JSTL not working in maven [message #1836345 is a reply to message #1836318] Tue, 29 December 2020 18:20 Go to previous messageGo to next message
Jim Whitaker is currently offline Jim WhitakerFriend
Messages: 26
Registered: October 2020
Junior Member
Yes I had already tried that did not work. Finally got it by adding:

<%@ page isELIgnored="false" %>


to the jsp file. I tried adding the following to pom:
<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>false</el-ignored>
    </jsp-property-group>
</jsp-config>



But that actually caused errors in the pom. Which I cannot understand why.

Remember I am new to maven, I feel I am forced to learn maven since jakarta will require maven builds.

A reminder I never ever had any problems with ant, it just worked perfect.

This little webapp was generated from a maven maven-archetype-webapp.

So how did it not get the jsp files to work without me adding the above line of code I showed.

I will say I do not like maven, I like ant, but if I am going to eventually do jakarta I have no choice but to use maven.

[Updated on: Tue, 29 December 2020 18:21]

Report message to a moderator

Re: JSTL not working in maven [message #1836358 is a reply to message #1836345] Wed, 30 December 2020 04:21 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4438
Registered: July 2009
Senior Member

Although it is a useful set of actions, JSPs don't require JSTL to function. jsp-config is a tag that goes in the web.xml, not the pom, hence Maven throwing up all sorts of error messages.

What was your original error message?


_
Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Wed, 30 December 2020 04:21]

Report message to a moderator

Re: JSTL not working in maven [message #1836371 is a reply to message #1836358] Wed, 30 December 2020 21:53 Go to previous messageGo to next message
Jim Whitaker is currently offline Jim WhitakerFriend
Messages: 26
Registered: October 2020
Junior Member
Here is untouched web.xml
<!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>Archetype Created Web Application</display-name>
  <servlet>
  	<servlet-name>Display</servlet-name>
  	<display-name>Display</display-name>
  	<description></description>
  	<servlet-class>net.Display</servlet-class>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Display</servlet-name>
  	<url-pattern>/Display</url-pattern>
  </servlet-mapping>
</web-app>


If I modify it to:
<!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>Archetype Created Web Application</display-name>
  <servlet>
  	<servlet-name>Display</servlet-name>
  	<display-name>Display</display-name>
  	<description></description>
  	<servlet-class>net.Display</servlet-class>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Display</servlet-name>
  	<url-pattern>/Display</url-pattern>
  </servlet-mapping>
  
  <jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>false</el-ignored>
    </jsp-property-group>
</jsp-config>
  
</web-app>

I get --  Element type "el-ignored" must be declared.

And same for all the elements.  And sorry earlier I meant web.xml, not pom.

[Updated on: Wed, 30 December 2020 21:53]

Report message to a moderator

Re: JSTL not working in maven [message #1836374 is a reply to message #1836371] Thu, 31 December 2020 04:25 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4438
Registered: July 2009
Senior Member

jsp-config wasn't added until Servlet 2.4, I think.


You'll need to replace the start of the file with:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">


_
Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Thu, 31 December 2020 04:31]

Report message to a moderator

Re: JSTL not working in maven [message #1836399 is a reply to message #1836374] Fri, 01 January 2021 19:30 Go to previous messageGo to next message
Jim Whitaker is currently offline Jim WhitakerFriend
Messages: 26
Registered: October 2020
Junior Member
That change give this error:

Content is not allowed in prolog.

This test project was created with maven-archetype-webapp.

[Updated on: Fri, 01 January 2021 19:43]

Report message to a moderator

Re: JSTL not working in maven [message #1836400 is a reply to message #1836399] Fri, 01 January 2021 20:09 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4438
Registered: July 2009
Senior Member

What do the contents of the web.xml look like now? Make sure there's no extra whitespace before the text at the start of the file.

_
Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Fri, 01 January 2021 20:16]

Report message to a moderator

Re: JSTL not working in maven [message #1836403 is a reply to message #1836400] Sat, 02 January 2021 01:25 Go to previous messageGo to next message
Jim Whitaker is currently offline Jim WhitakerFriend
Messages: 26
Registered: October 2020
Junior Member
I tried:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
  <display-name>Archetype Created Web Application</display-name>
  <servlet>
  	<servlet-name>Display</servlet-name>
  	<display-name>Display</display-name>
  	<description></description>
  	<servlet-class>net.Display</servlet-class>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Display</servlet-name>
  	<url-pattern>/Display</url-pattern>
  </servlet-mapping>
  <jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>false</el-ignored>
    </jsp-property-group>
</jsp-config>
</web-app>


Shouldn't maven archetype be creating something that works?

This: https://maven.apache.org/archetypes/maven-archetype-webapp/

But created in eclipse with maven dropdown.

Like I said it only works adding to jsp file:

<%@ page isELIgnored="false" %>


Exact same project in netbeans 12.2 works without that line of code.

So is this an eclipse bug?

[Updated on: Sat, 02 January 2021 01:27]

Report message to a moderator

Re: JSTL not working in maven [message #1836405 is a reply to message #1836403] Sat, 02 January 2021 04:30 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4438
Registered: July 2009
Senior Member

That depends on when you mean it "works", while working with the project in the IDE, or when running it on a server, from the IDE or not. Are you still getting the prolog-related error message after formatting the file?

I'm a little surprised that the Maven archetype generates a project against the 2.3 DTD, as well. That version is positively ancient. https://en.wikipedia.org/wiki/Jakarta_Servlet#History


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: JSTL not working in maven [message #1836411 is a reply to message #1836405] Sat, 02 January 2021 18:37 Go to previous messageGo to next message
Jim Whitaker is currently offline Jim WhitakerFriend
Messages: 26
Registered: October 2020
Junior Member
I can export a war, expand in tomcat, it runs, but my code.

I am also confused why an older servlet app was created. On my computer I have:

* jre1.8.0_271
* jdk-14.0.1
* Eclipse IDE 2020‑12 (Eclipse IDE for Enterprise Java Developers)
* Ide is set for auto update.

Yet in another project (dynamic web app) which of course is ant based, the web.xml has:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

///  more code not shown here


Never got any errors or problems. So what archetype do I need to use for an equivalent, but maven, dynamic web app? Or is this a bug in ide?



Re: JSTL not working in maven [message #1836414 is a reply to message #1836411] Sun, 03 January 2021 01:49 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4438
Registered: July 2009
Senior Member

Your first sentence ended with, "but my code." Where was that going?

Maven archetypes are owned by Maven, and from the CLI I also generated using the archetype and ended up with a file referring to the 2.3 DTD. That's not related to the IDE. I dare say https://github.com/apache/maven-archetypes needs a PR updating this.



_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: JSTL not working in maven [message #1836429 is a reply to message #1836414] Sun, 03 January 2021 20:19 Go to previous messageGo to next message
Jim Whitaker is currently offline Jim WhitakerFriend
Messages: 26
Registered: October 2020
Junior Member
My code, meaning in the jsp:
<%@ page isELIgnored="false" %>

Is the only thing that worked.

Will Eclipse eventually have a create a "dynamic web app" based on jakarta instead of java? I am not new to java, but brand new to jakarta.

I'd like to practice a simple jakarta web app with a:

* jakarta bean
* servlet
* jsp

I am guessing I will have to wait on next version. Also I use tomcat, it seems tomcat 10 should run such jakarta apps.

I am referring to Jakarta bean (old java bean term), not EJB.

Hard to believe there's not already some good starter tutorials. When I first learned java years ago, there were a lot of tutorials.

Also, in the past I always used IDE default (ANT), but looks like jakarta requires maven, thus I am trying to learn maven.

Just trying to get up to speed. If you search Google for:

* javabean servlet jsp web app tutorial (many "java" results)

But changing it to:

* jakartabean servlet jsp web app tutorial

You don't find "jakarta" results, still java results. A couple of simple tutorials would be helpful.

[Updated on: Sun, 03 January 2021 21:09]

Report message to a moderator

Re: JSTL not working in maven [message #1836498 is a reply to message #1836429] Wed, 06 January 2021 04:07 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4438
Registered: July 2009
Senior Member

It's one part having a Jakarta EE 9 runtime to target your project against, one part having the tools updated to work correctly with
either set of package names. WTP 3.20/2020-12 added support for Apache Tomcat 10, which means you can create such a project
right now if you want. Developers of the other server adapters will have to update their adapters when their servers have Jakarta EE 9
versions. The tooling half of the equation is a work in progress with some parts of it expected in 2021-03, but it's hard to predict for
projects under WTP where I have no direct involvement beyond encouraging them to think through and implement support.


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: JSTL not working in maven [message #1836532 is a reply to message #1836498] Thu, 07 January 2021 02:53 Go to previous messageGo to next message
Jim Whitaker is currently offline Jim WhitakerFriend
Messages: 26
Registered: October 2020
Junior Member
Thanks for reply. As mentioned above, Netneans 12.2 didn't have this problem, it's working with newer servlet. However, I cannot tell what archetype is used.
Is there some way to figure out what archetype was used when creating the project? Also the netbeans project doesn't have a web.xml. I used the maven bundled to create the project.

I did add a lib folder to WEB-INF and place the various taglibs jars, then it all worked.



Re: JSTL not working in maven [message #1836951 is a reply to message #1836532] Tue, 19 January 2021 19:11 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4438
Registered: July 2009
Senior Member

I'm not an expert, but I'd guess you can't without either knowing what command was used or by digging around in the archetypes themselves and making your own judgement.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:output from JSP console.log statements
Next Topic:worspace error
Goto Forum:
  


Current Time: Mon May 06 01:33:14 GMT 2024

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

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

Back to the top