Link to home
Start Free TrialLog in
Avatar of sudhakar_koundinya
sudhakar_koundinya

asked on

How to share data between Java Server Faces and normal JSPs/Servlets

Hi All,

How to share the data between Java Server Faces and normal JSPs. the session/request handling procedures are different from normal JSP coding. And I am always getting null in accessing the data

If any body of you guys know the solution plz help me

Thanks
Sudhakar
SOLUTION
Avatar of patbin
patbin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sudhakar_koundinya
sudhakar_koundinya

ASKER

Mogalmanic,

Do you think the model what you have given is pure JSF??
Reason why I am asking is

This is valid but at the same time studio Creator is considering as invalid. And the page similar to this when I created in Studio Creator, and included a small for loop, it is raising exception.

Could you plz tell me the reason for this??

Regards
Sudhakar

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<f:view>…
  <h:form>
<%
   for(int i=0;i<100;i++)
    {
%>
    Email address:
    <h:inputText value="#{registrationBean.email}"/><BR>    <!--Access the email property in the registration bean-->
    Password:
    <h:inputSecret value="#{registrationBean.password}"/><BR>
    <h:commandButton value="Sign Me Up!" action="#{registrationBean.register}"/>
<%
  }
%>
   </h:form>
</f:view>
This is what Studio Creator has created

<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
        <html lang="en-US" xml:lang="en-US">
            <head>
                <meta content="no-cache" http-equiv="Cache-Control"/>
                <meta content="no-cache" http-equiv="Pragma"/>
                <title>general$login Title</title>
                <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
            </head>
            <body style="-rave-layout: grid">
                <h:form binding="#{general$login.form1}" id="form1">
                    <h:outputText binding="#{general$login.outputText1}" id="outputText1" style="left: 72px; top: 96px; position: absolute" value="Login"/>
                    <h:outputText binding="#{general$login.outputText3}" id="outputText3" style="left: 72px; top: 144px; position: absolute" value="Password"/>
                    <h:inputText binding="#{general$login.txtLogin}" id="txtLogin" style="left: 168px; top: 96px; position: absolute"/>
                    <h:inputSecret binding="#{general$login.txtPasscode}" id="txtPasscode" style="left: 168px; top: 144px; position: absolute"/>
                    <h:commandButton action="#{general$login.btnLogin_action}" binding="#{general$login.btnLogin}" id="btnLogin"
                        style="left: 192px; top: 192px; position: absolute" value="Login"/>
                    <h:commandLink action="#{general$login.lnkNewRegister_action}" binding="#{general$login.lnkNewRegister}" id="lnkNewRegister" style="left: 384px; top: 96px; position: absolute">
                        <h:outputText binding="#{general$login.newRegisterText}" id="newRegisterText" value="Not yet Register?"/>
                    </h:commandLink>
                    <h:commandLink action="#{general$login.lnkForgotPassword_action}" binding="#{general$login.lnkForgotPassword}" id="lnkForgotPassword" style="left: 384px; top: 120px; position: absolute">
                        <h:outputText binding="#{general$login.forgotPasswordText}" id="forgotPasswordText" value="Link Action"/>
                    </h:commandLink>
                </h:form>
            </body>
        </html>
    </f:view>
</jsp:root>
what is the exception?

Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.

Exception Details: org.apache.jasper.JasperException
  /general/test.jsp(14,18) The content of elements must consist of well-formed character data or markup.

Possible Source of Error:
  Class Name: org.apache.jasper.compiler.DefaultErrorHandler
  File Name: DefaultErrorHandler.java
  Method Name: jspError
  Line Number: 43


I just used this simple code

 <%
                   for(int i=0;i<100;i++)
                %>
                    <h:selectBooleanCheckbox binding="#{general$test.checkbox1}" id="checkbox1" style="left: 144px; top: 168px; position: absolute"/>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial