*
The moose likes JSF and the fly likes Problem with  welcome-file-list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem with  welcome-file-list" Watch "Problem with  welcome-file-list" New topic
Author

Problem with welcome-file-list

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Normally i can access my page by typing http://localhost:8080/tech/index.faces but i would want to make chnages to the welcome file list such that a user only has to enter
http://localhost:8080/tech/

so, i made this entry in my web.xml

<welcome-file-list>
<welcome-file>/index.faces</welcome-file>
</welcome-file-list>
Now so any time i access the url i am receiving this exceptions

Faces context not found. getResponseWriter will fail. Check if the FacesServlet has been initialized at all in your web.xml configuration fileand if you are accessing your jsf-pages through the correct mapping. E.g.: if your FacesServlet is mapped to *.jsf (with the <servlet-mapping>-element), you need to access your pages as 'sample.jsf'. If you tried to access 'sample.jsp', you'd get this error-message.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Just create a simple HTML-file as welcome file which redirect to your index.jsp
like



Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Originally posted by Remko Strating:
Just create a simple HTML-file as welcome file which redirect to your index.jsp
like



Thanks but i tried it , still did'nt work
Tie CaiLiang
Greenhorn

Joined: May 20, 2007
Posts: 3
first in jsf page.you must have a FacesContext,so you must have a http request form out.so ,you need a simple html or htm to auto send a http request.Do this,the jsf create FacesContext then return response
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410



Take out the preceding slash.
Unlike a with a url-pattern, the welcome file entry is only looking for a file name (not a path or pattern).



Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
It's a shame it didn't work, because I could exactly simulate your error with your solution and with my solution it worked when I stared with JSF a year ago. I had the same problem.

I saw other rangers already give you some tips. I hope these were helpful.
Cristan Meijer
Greenhorn

Joined: Jan 24, 2011
Posts: 2
For the people getting here through Google, this is how I fixed it:

web.xml


index.jsp (a new file you have to create)


This has the advantage that you won't have to redirect your users to a second page using HTML.
Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218
Can't you just have welcome-file>faces/index.faces?
Cristan Meijer
Greenhorn

Joined: Jan 24, 2011
Posts: 2
Brendan Healey wrote:Can't you just have welcome-file>faces/index.faces?

Nope, it won't work because it isn't an existing file in the filesystem.
D hanu
Greenhorn

Joined: Jan 30, 2011
Posts: 4

the welcome file should be a pure html/jsp file without any jsf extension.

I tried the following and got a solution. The following is the index.jsp



And my web.xml looks like


So my url looks like http://server_address/appln_name/faces/login.jsp
I can access also through http://server_address/appln_name.

Use c:redirect instead of jsp:forward because jsp session gets invalidated during session timeout.
Hope this resolves your problem.
 
Consider Paul's rocket mass heater.
 
subject: Problem with welcome-file-list
 
Similar Threads
Problem with Beer-v1 example
Tomahawk filter brings HTTP 404
getting exception in JSF Tutorial of JR
Welcome file
Servlet Not working