Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with welcome-file-list

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just create a simple HTML-file as welcome file which redirect to your index.jsp
like

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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).

 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you just have welcome-file>faces/index.faces?
 
Cristan Meijer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic