Abhijit C
Abhijit C

Reputation: 313

Change URL of web application for deployment

I have developed a web based application using STRUTS 2.0 and I want to deploy it.I want to deploy two or more different instances one for user testing and one for production etc. I want to add namespace like my URL must be

http:\mysitename\abc\development\login.jsp for development environment http:\mysitename\abc\testing\login.jsp for testing environment.

I was thinking to create seperate copy of my project one for testing ,one for development and so on.

But can I do something like just add the name like development or testing in the URL so that it can be easy to identify which environment is running.and I wont need to change the images path and css files path in my project.

Something like editing my struts.xml or web.xml

Thanks in advance

Upvotes: 1

Views: 2264

Answers (2)

jddsantaella
jddsantaella

Reputation: 3687

If you do it properly and you do not hardcode you context path in your web application code there is not such an effort.

Here is what I use to do:

1 - write JSP that is imported in all jps. Let's called it taglibs.jsp and define a variable that contains the context path that it is got dynamically.

...
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
...

2 - import taglibs.jsp in the jsp you want to use it so you can use the variable:

<%@ include file="/taglibs.jsp"%>

3 - use ctx variable:

The same for images, javascript and whatever.

So, doing this, your application will not depend on the context path and for having to different versions you just need to change the war name.

Upvotes: 1

ch4nd4n
ch4nd4n

Reputation: 4197

I want to add namespace like my URL must be http:\mysitename\abc\development\login.jsp for development environment http:\mysitename\abc\testing\login.jsp for testing environment.

You can deploy it different application context instead. Like http://host/dev and http://host/test/ for doing this you don't need to do anything special in your config files. You could generate war with names dev.war or test.war (or rename it) and then deploy it.

Upvotes: 1

Related Questions