permaculture playing cards*
The moose likes JSF and the fly likes Uable to access jsp page from xhtml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Uable to access jsp page from xhtml" Watch "Uable to access jsp page from xhtml" New topic
Author

Uable to access jsp page from xhtml

Rahul Rajagopal
Greenhorn

Joined: Sep 21, 2010
Posts: 7
Hi guys,

I am new to jsf , i have a problem while accessing a jsp page from a xhtml page, my web.xml file is:

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>MyPetStore Application</display-name>
<description>
MyPetStore application.
</description>

<!-- JavaServer Faces -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
</context-param>

<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>


<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>


<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>



<filter>
<filter-name>Extensions Filter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>


<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- Tiles Servlet -->

<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>


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



</web-app>



and my xhtml page is as follows:


<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:util="http://java.sun.com/jsf/composite/util"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:t="http://myfaces.apache.org/tomahawk"
template="../layout/DefaultLayout.xhtml"
>
<ui:define name="PageTitle">
Add User
</ui:define>
<ui:define name="body">
<f:view>
<h:form id="home">

<h:inputHidden required="#{empty param['home:userId'] || fn:length(fn:trim(param['home:userId'])) eq 0 ||
empty param['home:userFirstName'] || fn:length(fn:trim(param['home:userFirstName'])) eq 0 ||
empty param['home:useLastName'] || fn:length(fn:trim(param['home:useLastName'])) eq 0}" />
<script type="text/javascript">
addClass2Menu2Open(1,1.1);
</script>

<script language="text/script" src="../script/js/jquery-1.4.2.js"></script>

<script language="javascript" >
function checkUsername()
{alert($("#home\\:userId").val());
$.get("CheckUserName.jsf",{username : $("#home\\:userId").val()},function updateUsername(response){
if (response) {
$("#usernameresult").text(response);
}});
alert("2");
}
</script>

<div class="title">
<h3>Add User</h3>
<div class="buttons">
<span><h:commandButton value="Save" action="#{userBean.save}" image ="../images/btn_Save.gif" /></span>
<a href="#"><img src="../images/btn_Reset.gif" alt="Reset" /></a>
<span><h:commandButton value="Cancel" action="#{userBean.cancel}" image ="../images/btn_Cancel.gif" /></span>

</div>
</div>
<div id="errorNwarning">
<h:messages styleClass="errorMessage" > </h:messages>
<span id="usernameresult" class="errorMessage" />
</div>

<div class="spaceTop">

<p class="mandatory fldmanditory">
<span>*</span>Mandatory Fields
</p>
</div>
<div class="clear">
</div>
<table class="horizontalTbl A">
<tr>
<td>User ID:</td>
<td>
<h:inputText class="txtNormal"
id="userId" value="#{userBean.userId}" maxlength="15" onkeypress="return blockSpecialChar(event)" onblur="return checkUsername()"/>
<label id="mandatorysign">*</label>
</td>
<td>First Name:</td>
<td>
<h:inputText class="txtNormal" id="userFirstName" value="#{userBean.userFirstName}" maxlength="15" onkeypress="return blockSpecialChar(event)"/><label id="mandatorysign">*</label>
</td>

</tr>
<tr>
<td>Middle Name:</td>
<td>
<h:inputText class="txtNormal" id="userMIddleName" value="#{userBean.userMIddleName}" maxlength="15" onkeypress="return blockSpecialChar(event)"/>
</td>
<td>Last Name:</td>
<td>
<h:inputText class="txtNormal" id="useLastName" value="#{userBean.userLastName}" maxlength="15" onkeypress="return blockSpecialChar(event)"/><label id="mandatorysign">*</label>
</td>

</tr>

<tr>
<td>Designation:</td>
<td>
<h:inputText class="txtNormal" id="designation" value="#{userBean.designation}" maxlength="15" onkeypress="return blockSpecialChar(event)"/>
</td>
<td>Email:</td>
<td>
<h:inputText class="txtNormal" id="email" value="#{userBean.email}" maxlength="100" onkeypress="return blockSpecialChar(event)" >
<t:validateEmail summaryMessage="Wrong Email Address!!"/>
</h:inputText>
</td>

</tr>


</table>




</h:form>
</f:view>
</ui:define>
</ui:composition>


in the above code i am using a javascript function checkUsername() inside which i called a jsp page CheckUserName.jsf. But the control is not going to the jsp page , but if it is given as CheckUserName.xhtml the control will go to that page.My CheckUserName.jsp page is as follows:

<%
String username = request.getParameter("username");
System.out.println("USER NAME:"+username);
if(username.equalsIgnoreCase("h")){
out.println("Username is already present ");

}


%>


Rahul Rajagopal
Greenhorn

Joined: Sep 21, 2010
Posts: 7
Hi,

Anybody please help to solve the issue..
Rahul Rajagopal
Greenhorn

Joined: Sep 21, 2010
Posts: 7
Hi,

Thank you for not answering my query, i was able to find it out by myself.



ranch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Uable to access jsp page from xhtml
 
Similar Threads
Multipart request problem
Problem with simple filter and JSF
JSF, Facelets losing context after reload
Error JSF 2.1: java.io.FileNotFoundException:*/*.xhtml Not Found in ExternalContext
Odd problem with RichFaces and Servlet Filter