Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove application name from URL

my site uses JSF and the url appears to be, http://mysitename.com/wompower6/faces/home.xhtml

I am using prettyfaces, so if I use the following in pretty-config.xml, i can change the name to http://mysitename.com/wompower6/home

<url-mapping id="home">
    <pattern value="/home" />
    <view-id value="/faces/home.xhtml" />
</url-mapping>

my questions are

  1. how can i remove the application name wompower6 , so that the url becomes mysitename.com/home ?

  2. in my web.xml, i have <welcome-file>home.xhtml</welcome-file>, but this does not seem to work. When i type, mysitename.com, it does not get mapped to home.xhtml. any clue here?

like image 570
user644745 Avatar asked Dec 22 '22 11:12

user644745


1 Answers

how can i remove the application name wompower6 , so that the url becomes mysitename.com/home?

This is a webapp <Context> setting and configuration is dependent on the servletcontainer used. If you're for example using Tomcat, then there are basically 2 options to make your webapp the root webapp.

  1. Rename the WAR file to ROOT.war and Tomcat will by default deploy it on context root.

  2. Set path attribute of <Context> element in Webapp/META-INF/context.xml (or Tomcat/conf/server.xml, depending where you'd like to define it) to an empty String. E.g.

    <Context path="" ...>
    

Other containers support similar constructs. Consult their documentation for detail. If you're using an IDE like Eclipse, then you can also set it in the Web Project Settings property of the project properties (rightclick project and choose Properties). Set the Context root value to just /.


in my web.xml, i have home.xhtml, but this does not seem to work. When i type, mysitename.com, it does not get mapped to home.xhtml. any clue here?

I assume that you're talking about the <welcome-file> setting. This has to point to a physically existing file, not to a virtual URL, such as /faces/*. There are basically two ways to overcome this:

  1. Provide a physically existing /faces/home.xhtml file (it can even be left empty).

  2. Replace the ugly /faces/* URL pattern of the FacesServlet mapping in web.xml by *.xhtml so that it will just kick in on every request for a XHTML file.

    <url-pattern>*.xhtml</url-pattern>
    

    This way you don't need to fiddle with /faces/* URL patterns.

like image 105
BalusC Avatar answered Jan 02 '23 12:01

BalusC