This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uable to access jsp page from xhtml

 
Rahul Rajagopal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Anybody please help to solve the issue..
 
Rahul Rajagopal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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



ranch
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic