4

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?

user644745
  • 5,673
  • 9
  • 54
  • 80

1 Answers1

11

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • As usual, it's again an excellent answer from you. let me do these changes and will update you. – user644745 Jul 01 '11 at 13:56
  • BalusC, everything seems to be working fine. I checked this in localhost. Thanks for enriching the forum by your knowledge and experience. – user644745 Jul 01 '11 at 18:34
  • While i tried the same war in mysitename.com, it still expects wompower6. I am using glassfish. Do i have to do any other configuration ? – user644745 Jul 01 '11 at 18:59
  • 3
    got the solution from http://markmail.org/message/uch2dfswtrgsuae2#query:+page:1+mid:6dcmavdydoxyppj3+state:results...... go to glassfish admin console, Configuration -> Virtual Servers -> There is a dropdown box with the label :Default Web Module. Select your web application as the default one. – user644745 Jul 01 '11 at 19:11
  • I have the same problem in jetty server.. what modifications will i have to do? help needed... – stallion Feb 24 '16 at 14:56