NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Navigation problems with JSF and servlet

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Futaleufu_John
Posted via mailing list.





PostPosted: Fri Feb 05, 2010 3:59 pm    Post subject: Navigation problems with JSF and servlet Reply with quote

I have a Flash chart in a JSF page (Manage_Schedules.jsp). The chart contains
links to a servlet (FindJobsServlet) that navigates to another JSF page
(Find_Jobs.jsp). When I click the link the JSF page displays fine. The
address bar shows
"http://localhost:8080/FindJobsServlet?jobId=2681&returnTo=manage_schedules".
When I click a button on the Find_Jobs JSF page the button's action method
doesn't execute. Instead I get a 404 error:

The requested resource (/FindJobsServlet/Find_Jobs.jsp) is not
available.

The requested resource should be /Find_Jobs.jsp.

So I can navigate from a JSF page to a servlet and from a servlet to a JSF
page but then navigation to another JSF page fails.

How do I fix this?

--
View this message in context: http://old.nabble.com/Navigation-problems-with-JSF-and-servlet-tp27469674p27469674.html
Sent from the Netbeans IDE Users mailing list archive at Nabble.com.
Back to top
Rick
Posted via mailing list.





PostPosted: Fri Feb 05, 2010 6:49 pm    Post subject: Navigation problems with JSF and servlet Reply with quote

Is "FindJobsServlet" the name of your JSF application?

It looks like a stand-alone servlet, in which case you would need to use
the path name of the jsf app. Generally it is of the form
"myProject/faces/Find_Jobs.jsp" unless you defined it differently in
your web.xml file.


Futaleufu_John wrote:
Quote:
I have a Flash chart in a JSF page (Manage_Schedules.jsp). The chart contains
links to a servlet (FindJobsServlet) that navigates to another JSF page
(Find_Jobs.jsp). When I click the link the JSF page displays fine. The
address bar shows
"http://localhost:8080/FindJobsServlet?jobId=2681&returnTo=manage_schedules".
When I click a button on the Find_Jobs JSF page the button's action method
doesn't execute. Instead I get a 404 error:

The requested resource (/FindJobsServlet/Find_Jobs.jsp) is not
available.

The requested resource should be /Find_Jobs.jsp.

So I can navigate from a JSF page to a servlet and from a servlet to a JSF
page but then navigation to another JSF page fails.

How do I fix this?

Back to top
jhalupka



Joined: 05 Feb 2010
Posts: 52

PostPosted: Sat Feb 06, 2010 10:14 am    Post subject: Navigation problems with JSF and servlet Reply with quote

The servlet is part of the JSF application.

I can navigate from a JSF page to the servlet. I can navigate from the
servlet to another JSF page using the following code in the servlet:

protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
LifecycleFactory lifecycleFactory =
(LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle =
lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
FacesContextFactory facesContextFactory =
(FacesContextFactory)FactoryFinder.
getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
FacesContext facesContext =
facesContextFactory.getFacesContext(getServletContext(), request, response,
lifecycle);
Application application = facesContext.getApplication();
ViewHandler viewHandler = application.getViewHandler();
String viewId = "/Manage_Schedules.jsp";
UIViewRoot view = viewHandler.createView(facesContext, viewId);
facesContext.setViewRoot(view);
String outcome = "find_jobs";
NavigationHandler navigationHandler =
application.getNavigationHandler();
navigationHandler.handleNavigation(facesContext, null, outcome);
lifecycle.render(facesContext);
}

Problems start when I try to navigate from Find_Jobs.jsp to another JSF page
or to execute an action handler in Find_Jobs.jsp.

That's when I get the unavailable resource error.

It appears that the context's URI gets out of whack.

Here are relevant entries in web.xml.

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FindJobsServlet</servlet-name>
<url-pattern>/FindJobsServlet</url-pattern>
</servlet-mapping>



Rick-141 wrote:
Quote:

Is "FindJobsServlet" the name of your JSF application?

It looks like a stand-alone servlet, in which case you would need to use
the path name of the jsf app. Generally it is of the form
"myProject/faces/Find_Jobs.jsp" unless you defined it differently in
your web.xml file.


--
View this message in context: http://old.nabble.com/Navigation-problems-with-JSF-and-servlet-tp27469674p27472785.html
Sent from the Netbeans IDE Users mailing list archive at Nabble.com.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo