Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<url-pattern> confusion

 
Ahmed Bin S
Ranch Hand
Posts: 378
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Ahmed Bin S
Ranch Hand
Posts: 378
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, great, thanks. Will look into context root for Wildfly.

PS, is there a reason you shun IDEs?
 
Ahmed Bin S
Ranch Hand
Posts: 378
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ahmed Bin S
Ranch Hand
Posts: 378
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic