aspose file tools*
The moose likes JSF and the fly likes How to display Welcome JSP Page for a Web Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to display Welcome JSP Page for a Web Application" Watch "How to display Welcome JSP Page for a Web Application" New topic
Author

How to display Welcome JSP Page for a Web Application

Sudharsan Ashwin
Greenhorn

Joined: Mar 09, 2010
Posts: 18
I have created a dynamic web application project using Eclipse.

ProjectName : DownloadFromLink

When I run the entire project (Right Click on the DownloadFromLink project in the Project Explorere Window and Run on Server),
a page opens having the address as "http://localhost/DownloadFromLink/" and my welcome jsp page that I have listed in web.xml is not displayed.

How to resolve this issue?
Pradeep Katipamula
Ranch Hand

Joined: May 11, 2010
Posts: 37
I am not sure on what port you have started the server. Just try adding a port number.

Pradeep
Sudharsan Ashwin
Greenhorn

Joined: Mar 09, 2010
Posts: 18
Yeah. I added that too. But still, it's not working.

Is it mandatory to add libarary files in WEB-INF/lib/ folder?

What should I do to display a page as my home page, as soon as i run the project?
Sudharsan Ashwin
Greenhorn

Joined: Mar 09, 2010
Posts: 18

When I run the project, the link displayed is this

http://localhost/DownloadFromLink/

and it shows an error like - org.apache.jasper.JasperException: An exception occurred processing JSP page /Downloadpdf.jsp at line 11"
line 11 is <f:view> tag

But, if I give the link as

http://localhost/DownloadFromLink/faces/Downloadpdf.jsp - the jsp is displayed and it works fine..

What is the problem?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

The problem is that the web application uses the "faces" part of your URL as an indicator that the URL request should be routed to the FacesServlet. Only the FacesServlet knows how to do JSF. If you attempt to access a JSF view directly, you'll get an error.

The mapping of URLs containing "/faces/" to the FacesServlet is done in the web.xml file.


Customer surveys are for companies who didn't pay proper attention to begin with.
Sudharsan Ashwin
Greenhorn

Joined: Mar 09, 2010
Posts: 18
Is it fine, if I get that error? Or how to rectify it?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Sudharsan Ashwin wrote:Is it fine, if I get that error? Or how to rectify it?


No error is really "fine", but that's what is supposed to happen. A "fine" solution would make the jsp view file inaccessible via a URL, but we rarely are granted enough time to enforce things like that.
Pradeep Katipamula
Ranch Hand

Joined: May 11, 2010
Posts: 37
I am not sure if you already have used the below but the welcome page mapping should be something like below



This should solve your problem. Hope this helps.

Pradeep
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

I'm afraid that won't work. The welcome page is dispatched internally by the server. For Tomcat, at least (and that includes JBoss), welcome, error, and login pages don't get routed through the standard channels, and therefore the FacesServlet doesn't get invoked.

Instead, setup a standard JSP that forwards to the JSF welcome page. It's annoying, but it works.
Sudharsan Ashwin
Greenhorn

Joined: Mar 09, 2010
Posts: 18
I tried <jsp:forward> from a jsp page to jsf page.

But, still

http://localhost/DownloadFromLink/

displays exception - FacesContext not found.
Pradeep Katipamula
Ranch Hand

Joined: May 11, 2010
Posts: 37
Tim Holloway wrote:I'm afraid that won't work.

I am currently using the same in one of our internal projects
But I am not sure with other servers. I will have to check out some time later.
Thanks anyways for your feedback

Pradeep
Pradeep Katipamula
Ranch Hand

Joined: May 11, 2010
Posts: 37
BTW I am using weblogic server.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display Welcome JSP Page for a Web Application
 
Similar Threads
how can i include a JSP in an HTML page?
cannot resolve symbol error when a class is imported from another project
Redirecting to a Page outside the web project
Apache Web Server
problem with web project in websphere