• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How do i bring in the attributes from Servlet to JSP using JSTL ?

 
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am using Jakaratee with jstl but really i have forgotten how to do it.

Basically, I have use the HTTPServletRequest  in my Controller to set attributes in order to bring it in to the jsp layer but i tried the entire morning, I can't make the attributes in.

Here's is a the code snippet to give you a clearer idea :



but in my jstl page, I am not able to bring the setAttributes that i want to display. I have put the jstl.jar onto the lib folder in the WEB-INF lib folder.



Hope I can get some answers here. Tks again

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Were you hoping that "{exlir." would print the attribute? That's wrong in several ways; try "${exlir}" instead.

I'll refrain from commenting on the JSP XML syntax, which has been out of fashion for many years.
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Were you hoping that "{exlir." would print the attribute? That's wrong in several ways; try "${exlir}" instead.

I'll refrain from commenting on the JSP XML syntax, which has been out of fashion for many years.



I managed to get the template fixed after searching for many hours but it is the web.xml that I am not sure now.





so i am not sure if the servlet-name should e restPostMan which is the context name or do i put /demo ?

and the jsp is



and the error i am getting is


SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restPostMan]]
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:878)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:912)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:795)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restPostMan]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871)
... 21 more
Caused by: java.lang.NoClassDefFoundError: retrofit2/Converter$Factory
at java.base/java.lang.Class.getDeclaredFields0(Native Method)



i have included the retrofit2 in Tomcat lib just to see if that is the caused, as suggested by SO but it is not helpful.

Hope I can get some answers here. Tks.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"<servlet-class>package controller.restController</servlet-class>" is wrong; remove the "package" part. Also note that class names should start with an uppercase letter.

Mappings never contain the context name.

Also note that "restPostMan" is the name of the servlet, not "restController" (which the form action uses).

We don't know what you have in WEB-INF/lib and TOMCAT_HOME/lib, but apparently not the class retrofit2.Converter. So you need to add whatever jar file contains that. Build tools like Maven and Gradle can handle dependency management for you.
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:"<servlet-class>package controller.restController</servlet-class>" is wrong; remove the "package" part. Also note that class names should start with an uppercase letter.

Mappings never contain the context name.

Also note that "restPostMan" is the name of the servlet, not "restController" (which the form action uses).

We don't know what you have in WEB-INF/lib and TOMCAT_HOME/lib, but apparently not the class retrofit2.Converter. So you need to add whatever jar file contains that. Build tools like Maven and Gradle can handle dependency management for you.



I already have it in my pom.  Now I added into TOMCAT_HOME/lib again as well as the WEB-INF/lib, it is still giving me the same error.

I am not sure what is wrong.  Attached i the tomcat configuration, do let me know if something is amissed. tks.
what-is-wrong-with-tomcat-configuration.png
[Thumbnail for what-is-wrong-with-tomcat-configuration.png]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

tangara goh wrote:I already have it in my pom.  Now I added into TOMCAT_HOME/lib again as well as the WEB-INF/lib, it is still giving me the same error.


It should be added to one of those directories, not both. Apparently you do not have it in your POM, or incorrectly so.

How have you ascertained that you do in fact have that class in a jar file in one of those directories? Tell us how you checked which jar file that class in is, and show us how that jar file is in one of those directories.

Seeing that you seem to run Tomcat inside of an IDE, I can easily picture the jar file not ending up in the correct runtime directory.
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

tangara goh wrote:I already have it in my pom.  Now I added into TOMCAT_HOME/lib again as well as the WEB-
Tell us how you checked which jar file that class in is, and show us how that jar file is in one of those directories.

Seeing that you seem to run Tomcat inside of an IDE, I can easily picture the jar file not ending up in the correct runtime directory.



Please see attached.

And snippet of my pom


<dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-databind</artifactId>
   <version>2.13.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit -->
<dependency>
   <groupId>com.squareup.retrofit2</groupId>
   <artifactId>retrofit</artifactId>
   <version>2.9.0</version>
</dependency>
<dependency>
 <groupId>com.squareup.retrofit2</groupId>
 <artifactId>converter-gson</artifactId>
 <version>2.9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
   <groupId>com.google.code.gson</groupId>
   <artifactId>gson</artifactId>
   <version>2.10.1</version>
</dependency>

show-jar-file-in-directory.png
[Thumbnail for show-jar-file-in-directory.png]
gson-converter-inside-tomcat-lib.png
[Thumbnail for gson-converter-inside-tomcat-lib.png]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That screenshot, rather pointedly, does NOT contain the jar file in which the class retrofit2.Converter lives. I'll ask again:

Tell us how you checked which jar file that class in is, and show us how that jar file is in one of those directories.

 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:That screenshot, rather pointedly, does NOT contain the jar file in which the class retrofit2.Converter lives. I'll ask again:

Tell us how you checked which jar file that class in is, and show us how that jar file is in one of those directories.



the name is converter-gson which is from retrofit2

<dependency>
 <groupId>com.squareup.retrofit2</groupId>
 <artifactId>converter-gson</artifactId>
 <version>2.9.0</version>
</dependency>
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll ask yet again, hoping that you will actually do it this time:

Tell us how you checked which jar file that class is in



Because the converter-gson jar file does NOT contain the missing class.

If you want help you need to pay attention to what people are telling you.
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:I'll ask yet again, hoping that you will actually do it this time:

Tell us how you checked which jar file that class is in



Because the converter-gson jar file does NOT contain the missing class.

If you want help you need to pay attention to what people are telling you.


ok. i think i know what you meant.

and i proceeded to add the respective files - retrofit files including okhttp3 etc

btw, it's never ending with the latest java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics but thank you so much and sorry I did not understand what you meant tks so much to make me wake up and read your message carefully.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't download anything from the Maven site, you should let Maven do this. That is what dependency management systems are for.

I have no way of knowing whether some file on your disk is broken or incomplete. What I do know is that the "converter-gson" dependency simply does not contain the class retrofit2.Converter. That is why I keep asking how you have made sure that it does. Because it doesn't, and it baffles me how you might have gotten that idea.
 
Saloon Keeper
Posts: 28325
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DO NOT go slapping user code into TOMCAT_HOME/lib. That's not what it's for. It's for Tomcat itself and tomcat shared resources such as JDBC drivers used by Tomcat JDBC Connection pools.

It would also help if you'd pretty-print (indent) your XML. Kind of hard to read there.

Basically, the process you're describing goes like this:

1. User submits a URL request. Tomcat has a map of URL patterns which it builds from servlet annotations (if present) and the /WEB-INF/web.xml WAR file (if present. web.xml overrides annotations, by the way.

2. Using the URL pattern map, Tomcat determines which servlet in the WAR to route the URL request to. If using web.xml, there's an abstraction where the pattern maps to a logical servlet name, which is then mapped to a servlet class.

3. The servlet does its thing and puts stuff it wants to display in JEE-scoped (request, session or application) named objects. It then forwards to the display JSP.

4. The display JSP (which internally gets compiled into a servlet itself) generates the output using the tags (including JSTL) and other dynamic properties such as Uniform Expression Laguage (UEL) expressions. The output then gets sent back to the requester for display.

If you're going to display a table, defining the table row in a c:forEach JSTL element is usually the way to go. Referenced to variable values are commonly done in UEL which defines a syntax that allows naming individual properties and sub-properties, including Map lookups and array indexed elements and is more detail that the current reply warrants. You use UEL, or simply named, "EL", to indicate escapting normal verbatim text copying, so for JSTL tags. you may see a variable named directly instead of via the EL "${name}" syntax. There's also a "#{name}" EL syntax, but it's used mostly by JavaServer Faces, as it designates a read/write reference, not a read-only reference.

As an example of more complex EL, the expression "${foo.bar}" means that EL will search the scopes for an object named "foo" and invoke its "getBar()" method to retrieve that property value. "${foo.bazz[5].id}" would expect that the getBazz() method on foo would return an iterable object such an array or list, look up the object on the 6th (offset from 0!) row, and invoke that object's "getID()" method.
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You shouldn't download anything from the Maven site, you should let Maven do this. That is what dependency management systems are for.

I have no way of knowing whether some file on your disk is broken or incomplete. What I do know is that the "converter-gson" dependency simply does not contain the class retrofit2.Converter. That is why I keep asking how you have made sure that it does. Because it doesn't, and it baffles me how you might have gotten that idea.



yes. so i am really puzzled why with maven - and i updated it, cleaned and installed it so many times, why would i still need to install the jars manually ?

here is the relevant dependencies

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and i updated it, cleaned and installed it so many times


Why would you uninstall it? It's working, isn't it? You really need to focus less on your tools, and more on getting stuff done.

why would i still need to install the jars manually ?


You don't, as I keep telling you. Of course, currently your Maven POM does nothing with those dependencies. You need to add something about Maven creating a war file. See https://www.baeldung.com/maven-generate-war-file for an introduction; section 3 contains the first step.
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


why would i still need to install the jars manually ?


You don't, as I keep telling you. Of course, currently your Maven POM does nothing with those dependencies. You need to add something about Maven creating a war file. See https://www.baeldung.com/maven-generate-war-file for an introduction; section 3 contains the first step.

I have rewritten based on your hints. Tks.
Here's the new pom but I am stuck at the output it to Tomcat directory which is in that frustrating Windows 0S that gives me a access denial.  So, not to waste time, I chose to output it to a User directory and then added in a embedded tomcat.

But, when i run the server, this is the part that gets communicated, as it seem Eclipse will somehow call a Tomcat server which is not the embedded one.

How can I best navigate all these obstacles that is blocking my progress to the jsp which I have yet to figure out things?



so, basically, i got to learn the way from https://www.youtube.com/watch?v=xsfRSrDgBWI

and now the error is :


SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:878)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:912)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:795)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871)
... 21 more
Caused by: java.lang.NoClassDefFoundError: jakarta/servlet/jsp/JspFactory
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappServiceLoader.java:235)
at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:206)
at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1834)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1299)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:987)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:304)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4797)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 27 more



and it is quite strange that i already have jakarta.servlet.jsp.jstl it is still complaing i need   jakarta/servlet/jsp/JspFactory

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and it is quite strange that i already have jakarta.servlet.jsp.jstl it is still complaing i need   jakarta/servlet/jsp/JspFactory


That sentence does not make sense. JSP and JSTL are different things. JSP is built into a servlet container, whereas JSTL needs to be added.

There seems to be a disconnect between the libraries you compile against, and the libraries (meaning, the Tomcat version) that you run the code on. I advise not to use the IDE for this, but to use a standalone Tomcat for running your code. That way you will know exactly what version of the libraries is used.

Let's take a look: "org.apache.tomcat.embed" - you almost certainly don't need this, as it doesn't sound like you're embedding a Tomcat.

"javax.servlet.jsp" - this is so old that's not even funny that it would be included in a current web app. But more importantly, it's the wrong version. It uses the javax.servlet namespace, whereas Tomcat 10.1.6 uses jakarta.servlet. For Tomcat 10.1, you need to use https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api/6.0.0

What is causing this particular issue is likely the "jstl-1.2.jar" you have in TOMCAT_HOME/lib. That, too, is horribly outdated, and what's more, based on javax.servlet. The POM states that the container provides 3.0.1 of jakarta.servlet.jsp.jstl, so that's what you need to install. The relevant files are https://repo1.maven.org/maven2/jakarta/servlet/jsp/jstl/jakarta.servlet.jsp.jstl-api/3.0.0/jakarta.servlet.jsp.jstl-api-3.0.0.jar and https://repo1.maven.org/maven2/org/glassfish/web/jakarta.servlet.jsp.jstl/3.0.1/jakarta.servlet.jsp.jstl-3.0.1.jar
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

and it is quite strange that i already have jakarta.servlet.jsp.jstl it is still complaing i need   jakarta/servlet/jsp/JspFactory


That sentence does not make sense. JSP and JSTL are different things. JSP is built into a servlet container, whereas JSTL needs to be added.

There seems to be a disconnect between the libraries you compile against, and the libraries (meaning, the Tomcat version) that you run the code on. I advise not to use the IDE for this, but to use a standalone Tomcat for running your code. That way you will know exactly what version of the libraries is used.



Hi Ulf, I have put in all the lib that you mentioned.  Now, when I run the server on standalone, it gives me the same error, even though the index page could be displayed.

Please find attached.

using-standalone-tomcat-but-still-getting-same-error.png
[Thumbnail for using-standalone-tomcat-but-still-getting-same-error.png]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message does indicate that not all jar files are where they should be, or that some jar files are the wrong versions. If you post the contents of TOMCAT_HOME/lib and WEB-INF/lib, maybe we can help you.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Now, when I run the server on standalone,


You're running Tomcat in an IDE - that is not "standalone".
 
Tim Holloway
Saloon Keeper
Posts: 28325
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:The error message does indicate that not all jar files are where they should be, or that some jar files are the wrong versions. If you post the contents of TOMCAT_HOME/lib and WEB-INF/lib, maybe we can help you.



And, again, DO NOT put application JAR files into TOMCAT_HOME/lib. That includes application library JARs!!!
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:

Ulf Dittmer wrote:The error message does indicate that not all jar files are where they should be, or that some jar files are the wrong versions. If you post the contents of TOMCAT_HOME/lib and WEB-INF/lib, maybe we can help you.



And, again, DO NOT put application JAR files into TOMCAT_HOME/lib. That includes application library JARs!!!



The content of Tomcat Lib is quite huge.  Is it possible to attached a compressed file here?

I tried to attempt the stand alone Tomcat and I can't find any tutorial that can guide me how to operate a Tomcat server without IDE.

Can I have some guidance how I can test things out in Tomcat.

I got a reply from SO that I just dropped the entire Jakarata EE lib onto Tomcat and the error it will help.  It did work but still I got to iron out all the dependencies as I need it for CICD.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

tangara goh wrote:The content of Tomcat Lib is quite huge.  Is it possible to attached a compressed file here?


What we would need to see is not the files, but the list of files - in text, NOT as a screenshot.

I tried to attempt the stand alone Tomcat and I can't find any tutorial that can guide me how to operate a Tomcat server without IDE.


Start here: https://tomcat.apache.org/tomcat-10.1-doc/setup.html

I got a reply from SO


Oh, you are also asking this elsewhere, without mentioning this here? And probably without mentioning it there? Thus duplicating effort and wasting people's time? You've been here long enough to know that that's unfriendly behaviour.  I just lost interest in helping you. Good bye.
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

tangara goh wrote:The content of Tomcat Lib is quite huge.  Is it possible to attached a compressed file here?


What we would need to see is not the files, but the list of files - in text, NOT as a screenshot.

I tried to attempt the stand alone Tomcat and I can't find any tutorial that can guide me how to operate a Tomcat server without IDE.


Start here: https://tomcat.apache.org/tomcat-10.1-doc/setup.html

I got a reply from SO


Oh, you are also asking this elsewhere, without mentioning this here? And probably without mentioning it there? Thus duplicating effort and wasting people's time? You've been here long enough to know that that's unfriendly behaviour.  I just lost interest in helping you. Good bye.



Er I need an answer fast so I do hope you understand that I am running out of money i need to complete this assignment.

but, today i found out that solution doesn't work.  


Managed to copy it to txt :

01/03/2023  11:34 pm    <DIR>          .
01/03/2023  11:34 pm    <DIR>          ..
01/03/2023  12:06 am            14,122 annotations-api.jar
01/03/2023  12:06 am            55,980 catalina-ant.jar
01/03/2023  12:06 am           125,174 catalina-ha.jar
01/03/2023  12:06 am            63,435 catalina-ssi.jar
01/03/2023  12:06 am            78,936 catalina-storeconfig.jar
01/03/2023  12:06 am           324,727 catalina-tribes.jar
01/03/2023  12:06 am         1,702,785 catalina.jar
28/02/2023  09:21 pm             4,618 converter-gson-2.9.0.jar
01/03/2023  12:06 am         3,237,597 ecj-4.26.jar
01/03/2023  12:06 am            89,303 el-api.jar
01/03/2023  11:34 pm            71,370 jakarta.servlet.jsp-api-3.1.1.jar
01/03/2023  05:41 pm         3,711,043 jakarta.servlet.jsp.jstl-3.0.1.jar
01/03/2023  05:40 pm            46,041 jakarta.servlet.jsp.jstl-api-3.0.0.jar
01/03/2023  12:06 am           763,944 jakartaee-migration-1.0.6-shaded.jar
01/03/2023  12:06 am           172,849 jasper-el.jar
01/03/2023  12:06 am           569,478 jasper.jar
01/03/2023  12:06 am            28,466 jaspic-api.jar
01/03/2023  12:06 am           365,683 servlet-api.jar
01/03/2023  12:06 am            11,568 tomcat-api.jar
01/03/2023  12:06 am           870,285 tomcat-coyote.jar
01/03/2023  12:06 am           335,540 tomcat-dbcp.jar
01/03/2023  12:06 am            68,468 tomcat-i18n-cs.jar
01/03/2023  12:06 am            77,387 tomcat-i18n-de.jar
01/03/2023  12:06 am           104,046 tomcat-i18n-es.jar
01/03/2023  12:06 am           168,730 tomcat-i18n-fr.jar
01/03/2023  12:06 am           191,578 tomcat-i18n-ja.jar
01/03/2023  12:06 am           192,783 tomcat-i18n-ko.jar
01/03/2023  12:06 am            52,068 tomcat-i18n-pt-BR.jar
01/03/2023  12:06 am            49,200 tomcat-i18n-ru.jar
01/03/2023  12:06 am           175,966 tomcat-i18n-zh-CN.jar
01/03/2023  12:06 am           149,512 tomcat-jdbc.jar
01/03/2023  12:06 am            16,118 tomcat-jni.jar
01/03/2023  12:06 am           229,256 tomcat-util-scan.jar
01/03/2023  12:06 am           204,082 tomcat-util.jar
01/03/2023  12:06 am           240,150 tomcat-websocket.jar
01/03/2023  12:06 am            14,748 websocket-api.jar
01/03/2023  12:06 am            31,697 websocket-client-api.jar
             37 File(s)     14,608,733 bytes
              2 Dir(s)  15,923,810,304 bytes free

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Er I need an answer fast so I do hope you understand


I do understand your predicament, but I have no sympathy for you not mentioning it. You have been here long enough to have been reminded of this several times, yet you chose to ignore that once again. See https://coderanch.com/wiki/660346/Forthright-Cross-Posting-Sites for more information on that. So, as part of your next post, include links to all the places where you asked about this as well, so that we don't duplicate any more effort.

OK, that looks like a pretty clean Tomcat, except for converter-gson-2.9.0.jar. That's part of your web app, and belongs into WEB-INF/lib, together with the other dependencies (like Retrofit).
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:OK, that looks like a pretty clean Tomcat, except for converter-gson-2.9.0.jar. That's part of your web app, and belongs into WEB-INF/lib, together with the other dependencies (like Retrofit).


Actually, jakarta.servlet.jsp-api-3.1.1.jar  looks suspicious. Wasn't there a jsp-api.jar file initially? Mucking around with Tomcat's internal files is a recipe for desaster.
 
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Actually, jakarta.servlet.jsp-api-3.1.1.jar  looks suspicious. Wasn't there a jsp-api.jar file initially? Mucking around with Tomcat's internal files is a recipe for desaster.


I'm only speculating here, but it's very likely that the names of these files changed with Tomcat 10, since Tomcat 10 moved from Java EE to Jakarta EE.
 
tangara goh
Ranch Hand
Posts: 1048
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

Ulf Dittmer wrote:OK, that looks like a pretty clean Tomcat, except for converter-gson-2.9.0.jar. That's part of your web app, and belongs into WEB-INF/lib, together with the other dependencies (like Retrofit).


Actually, jakarta.servlet.jsp-api-3.1.1.jar  looks suspicious. Wasn't there a jsp-api.jar file initially? Mucking around with Tomcat's internal files is a recipe for desaster.



Should I remove that jar ?

now, I tried out using jetty with eclipse and then it gives me error like this :


|java.lang.RuntimeException: Error scanning entry org/apache/taglibs/standard/tlv/JstlSqlTLV$Handler.class from jar file:///C:/Users/abc/xxx/abc-workSpace/restPostMan/src/main/webapp/WEB-INF/lib/jakarta.servlet.jsp.jstl-3.0.1.jar



the jar is also attached.

But, if i removed all the jars and the dependencies that Jetty is complaining, now it says it can't find my Controller.class.

I read that Eclipse inherited the Jakaratee EE, so it could be part of Eclipse, will the dependencies means redundant jars and so they are not supposed to be in ? What about Jetty since this is a Eclipse-jetty plug in I am using. ?
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I'm only speculating here, but it's very likely that the names of these files changed with Tomcat 10, since Tomcat 10 moved from Java EE to Jakarta EE.


Wait no, never mind. I see that that file was added or changed after the installation of Tomcat.

Tangara Goh, you really should not be changing ANY of the files in your Tomcat installation unless you understand exactly what you're doing and why you're doing it. Simply adding libraries to Tomcat just because your application is complaining about it is a BAD idea.

It's probably best that you get rid of your Tomcat installation and start fresh. When you've done this, you can probably solve your problem by removing <scope>provided</scope> from the JSTL dependency in your POM, as this scope is only used when the dependency is provided by your application server. Tomcat does NOT provide this dependency, so the provided scope is wrong.
 
Tim Holloway
Saloon Keeper
Posts: 28325
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:
Tangara Goh, you really should not be changing ANY of the files in your Tomcat installation unless you understand exactly what you're doing and why you're doing it. Simply adding libraries to Tomcat just because your application is complaining about it is a BAD idea.



What I tell you three times is True.

Almost none of the JAR files in TOMCAT_HOME/lib have version numbers in their names. That's because the only valid version is the one that came with Tomcat. Mess with them at your extreme peril.

To run Tomcat stand-alone:

1. Download the appropriate Tomcat ZIP file from tomcat.apache.org.

2. UNZIP it into a suitable directory. This can be your home directory for testing purposes.

3. Deploy your webapp into Tomcat. Generally you'd copy a WAR into TOMCAT_HOME/webapps.

4. CD into the root directory of the unzipped Tomcat. That's your TOMCAT_HOME. Start Tomcat from the command line. For Windows: For Linux/Unix/MacOS:

You can also install via Windows MSI, which allows you to run Tomcat as a Windows Service, but I don't recommend doing that until you understand how Tomcat works.

For debugging, point your IDE at the copy of Tomcat you just installed (TOMCAT_HOME).

Note that "TOMCAT_HOME" is our generic name for the root of Tomcat. Its actual name would be something like apache-tomcat-7.0.41 to use an outdated example.
 
Fire me boy! Cool, soothing, shameless self promotion:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic