Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display Welcome JSP Page for a Web Application

 
Sudharsan Ashwin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure on what port you have started the server. Just try adding a port number.

Pradeep
 
Sudharsan Ashwin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sudharsan Ashwin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it fine, if I get that error? Or how to rectify it?
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW I am using weblogic server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic