Forums Register Login

<url-pattern> confusion

+Pie Number of slices to send: Send
Hello,

I am creating my first servlet (well, technically I am not, as I did this stuff in 2010 but as I have forgotten it all, for all intents and purposes I am!).

I am creating it using the New Dynamic Web Project in Ecplise (and am using Wildfly 10).

My deployment descriptor is below, and my application is LearningServlets.jar. What I would like is to map the servlet to a URL that doesn't have LearningServlets in it i.e. localhost:8080/Intro, and not localhost:8080/LearningServlets/Intro.
I tried hardcoding the entire URL in but it didn't work. Any ideas would be appreciated.

Thank you.

1
+Pie Number of slices to send: Send
 

Ahmed Bin S wrote:i.e. localhost:8080/Intro, and not localhost:8080/LearningServlets/Intro.



That's not the way things work by default. A servlet container will usually requires that the first thing in the URL path be the context path, in your case /LearingServlets.

In Tomcat, you can make the application the ROOT web context and the context path will simply be /.

I have no idea how to make that happen running in an IDE (which I do not do).
+Pie Number of slices to send: Send
Ah, great, thanks. Will look into context root for Wildfly.

PS, is there a reason you shun IDEs?
+Pie Number of slices to send: Send
Thanks, you were right, I had to set the context-root to /.

For Wildfly, this can be done by creating a jboss-web.xml file under WEB-INF, and adding the following:


1
+Pie Number of slices to send: Send
 

Ahmed Bin S wrote:PS, is there a reason you shun IDEs?



I use my IDEs as smart editors. What I don't do is to run the servlet container in the IDE because it adds extra complexity and doesn't adequately mimic the real-world environment that the app will eventually run in. I run my own separate instances of the servlet container.
1
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:

Ahmed Bin S wrote:PS, is there a reason you shun IDEs?



I use my IDEs as smart editors. What I don't do is to run the servlet container in the IDE because it adds extra complexity and doesn't adequately mimic the real-world environment that the app will eventually run in. I run my own separate instances of the servlet container.



Ah, thanks for clarifying - that makes perfect sense.
His brain is the size of a cherry pit! About the size of this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 727 times.
Similar Threads
Making attributes from textboxes available to other servlets and storing the latest passed variable.
Running a servlet on Tomcat using Eclipse
Error 404 in jsp
HTTP 404 The requested resource is not available.
HTTP Status 404 - /ServletDemoOne/
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 21:58:21.