1

i'm working in a project with jsp, i need to start to use ajax too. i'm enjoying jsf , is possible work with these together (JSP, JSF and AJAX) ?

I'm asking this cause i could run jsf with ajax

<h:commandButton id="bt_save" value="Save" title="Save" action="#personMBean.clickSave()}">
    <f:ajax execute="@form" render="lblMessage" />
</h:commandButton>
<br/>

<h:outputLabel id="lblMessage" value="#{personMBean.message}" />

But when i try input this code in my jsp page it doesn't work, even if i insert on my jsp page:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

Any ideas ?

4
  • 1
    Do you have dependencises for jsf in your project? Is Your project configured to work witj jsf? Why would you want to combine jsf and jsp? Commented Jun 13, 2011 at 13:44
  • i want unite both technologies Eduard , get the best features of both. Commented Jun 13, 2011 at 13:47
  • JSP is in no way better than Facelets. Commented Jun 13, 2011 at 16:50
  • 1
    I would go a bit further even and say JSP is plain wrong in combination with JSF today. There are absolutely no best features of both to combine. The only reason to have JSP in a project together with JSF is if you're unlucky to still have legacy pages. This is tolerable if the situation is temporary. Otherwise, don't do it. Commented Jun 13, 2011 at 20:18

3 Answers 3

2

Ensure that you're using JSF 2.x (the <f:ajax> doesn't exist in JSF 1.x) and that you've a <h:head> instead of <head> in the master template (so that JSF can auto-include necessary Ajax JavaScripts).

Said that, you should really consider Facelets as replacement of JSP. JSP is an outdated view technology and ill suited for templating and has been replaced by Facelets as per JSF 2.0 / Java EE 6.

Sign up to request clarification or add additional context in comments.

Comments

0

Yes - try richfaces or primefaces

Comments

0

I don't see why you couldn't do this but certainly not on the same page.

To do this you need to map the *.jsp extension to the JSP servlet while mapping the *.jsf or *.xhtml to FacesServlet.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.