Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Configure different context path in the same Spring application context

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, i have a issue about managing context path of my wab app. I have my web application ( with an application context) deployed into tomcat 7.
My URL looks like this: http://localhost:8080/myapp
myapp - is the application context here.

Now i need to split "myapp" name in three single one context path into the same application context.
myapp1: http://localhost:8080/myapp1 - same application context "myapp"
myapp2: http://localhost:8080/myapp2 - same application context "myapp"
myapp3: http://localhost:8080/myapp3 - same application context "myapp"

I think i could use @RequestMapping to enroute the request and remove path name from the web.xml, but it seams to be complicated.
There is a best way in Spring to do that?
 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create 3 applications - one for each context, and have a single index.html file to redirect to 'myapp'.
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only one context per application.

Why do you want do that?
 
Luigi Mattino'
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because i need to get separate those three context.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In any Java based web application, the URL is http://<servername>:<port>/<webappname>/<uri>; unless you deployed in Root.. in which case it's http://<servername>:<port>/<uri>. THe part inside <uri> is what spring handles. Outside that part is out of Spring's control and is managed by the Web Server

So, how you go from hosting Urls on myapp/ to myapp1/ myapp2/ myapp3/ depdends on how you have it deployed right now. Are you deployed into myapp.. or are you deployed into Root? If you are in Myapp, you need to split into 3 seperate wars. If you are in root, all you do is change the Spring MVC mapping between URIs and controllers
 
Luigi Mattino'
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jayesh, thank you for your answer.
I don't deploy my web app (war file) into ROOT, but if it is necessary how i map the URIs to the controllers?
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic