Accessing bean attributes in a JSP
Hi,
I am sending a bean from a Servlet to a JSP as follows:
request.setAttribute("newclientTEST", ro_client);
this.getServletContext().getRequestDispatcher("/jsp/private/research/UserAdded.jsp").forward(request,
response);I can then access the bean in UserAdded.jsp page as follows:
<jsp:getProperty name="newclientTEST" property="username" />This works fine and returns the username from the bean but I am a little confused why this is working. From what i have read about JSPs so far in order to access properties of a bean in a JSP we first of all have to make a reference to the bean as follows:
<jsp:useBean id="newclientTEST" scope="request" class="ie.scourced.beans.PrivateClientBean" />Why does it work for me when I don't refer to the bean using useBean??
Thanks
how?.... mmmm ... did ... (head scratch) ...I miss that.
Thanks a million for spotting that, I really did appreciate that.
jp.
Similar Messages
-
Accessing bean properties in a jsp
Hi,
I am trying to access a bean in my jsp page like this,
<c:out value="${clientSession.customerName}"/>
I validate and then set the bean in my action class, I am using struts 1.1,
package com.neo.five.ereports;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import com.neo.five.cookies.SessionCookieValidator;
import com.neo.five.beans.CustomerSessionBean;
public final class EreportAction extends Action{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
//get the session object
HttpSession session = request.getSession(false);
//validate the session cookie if session object dows not exist
Cookie[] cookies = request.getCookies();
SessionCookieValidator scv = new SessionCookieValidator(cookies);
scv.checkCookie();
//forward to appropriate destination
//if there is a cookie continue
if(scv.hasSessionCookie()){
//check for session object
if (session != null) {
//if session does not exist put bean into session that holds the cookie
//values
if(session.getAttribute("cookieSession")==null){
CustomerSessionBean sb = new CustomerSessionBean(scv.getCustomerid(),scv.getCustomerName(),scv.getCfid(),scv.getCftoken());
session.setAttribute("cookieSession", sb);
request.setAttribute("clientSession",sb);
return (mapping.findForward("success"));
}else{
return (mapping.findForward("failure"));
}else{
return (mapping.findForward("failure"));
}this is my SessionBean
package com.neo.five.beans;
public class CustomerSessionBean {
private int customerid;
private String customerName;
private int cfid;
private int cftoken;
public CustomerSessionBean(int customerid,String customerName,int cfid,int cftoken){
this.customerid=customerid;
this.customerName=customerName;
this.cfid=cfid;
this.cftoken=cftoken;
public int getCustomerid(){
return customerid;
private String getCustomerName(){
return customerName;
private int getCfid(){
return cfid;
private int getCftoken(){
return cftoken;
}however I am getting this error,
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An error occurred while evaluating custom action attribute "value" with value "${clientSession.customerName}": Unable to find a value for "customerName" in object of class "com.neo.five.beans.CustomerSessionBean" using operator "." (null)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)
root cause
javax.servlet.ServletException: An error occurred while evaluating custom action attribute "value" with value "${clientSession.customerName}": Unable to find a value for "customerName" in object of class "com.neo.five.beans.CustomerSessionBean" using operator "." (null)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
at org.apache.jsp.eReportDeskTopRoot_jsp._jspService(eReportDeskTopRoot_jsp.java:145)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)
Apache Tomcat/4.1.30
thanks for any help.how?.... mmmm ... did ... (head scratch) ...I miss that.
Thanks a million for spotting that, I really did appreciate that.
jp. -
Accessing session attribute in output jsp page
Hi i am not getting any output in jsp page...
i am getting just heading
i think some problem with Session attribute..
if so how to access session been in jsp page
my code is here
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Tauvex Search Output</title>
</head>
<body>
Tauvex Search Output
<table>
<c:forEach items="${myDataList}" var="myData">
<tr>
<td>${myData.Fitsfilename}</td>
<td>${myData.RA_START}</td>
<td>${myData.RA_END}</td>
<td>${myData.DEC_START}</td>
<td>${myData.DEC_END}</td>
<td>${myData.telescope}</td>
<td>${myData.STARTOBS}</td>
<td>${myData.ENDOBS}</td>
<td>${myData.FILTER}</td>
</tr>
</c:forEach>
</table>
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
</body>
</html>
plz reply soon
thanks a lotthis is what i set in servlet
request.setAttribute("myDataList", myDataList);
request.getRequestDispatcher("someJspFile.jsp").forward(request, response);
how can i access that session attribute in jsp -
Assining a bean attribute to a jsp variable
I am writing a struts application and am using
<bean:write name="configattribute" property="name"/>
to print out info on my jsp page.
I was wondering if I could assign that value to a local jsp variable so I can check its value and change the colour of the text accordingly.
e.g.
String name = <bean:write name="configattribute" property="name"/>;
if name.equals("Ben"){
out.print(<font color=\"red\">;
else{
out.print(<font color=\"blue\">;
}You should still be able to use the code I listed...the logic:iterate tag creates the bean "configname" in the page scope. So you should be able to do something like this:
<logic:iterate id="configname" name="confignames">
<tr>
<td>
<% ConfigName configname = (ConfigName)pageContext.getAttribute( "configname" );
String color = "blue";
if( "julius".equalsIgnoreCase( configName.getOwner( ) ) )
color = "red";
} %>
<span style="color: <%= color %>"><bean:write name="configname" property="owner"/></span>
</td>
<td>
<bean:write name="configname" property="name"/>
</td>
</tr>
</logic:iterate>Does that sound right?
- Jesse -
Using Bean Attributes in a JSP for a h:commandLink
Hi,
I am very new to JSF so apologies if the answer is obvious.
I currently have a ArrayList of products obtained from a database.
Using...
<h:dataTable value="#{ProductBean.productList}" var="product">
<h:column>
<f:facet name="header" >
<h:outputText value="Title"/>
</f:facet>
<h:outputText value="#{product.title}"/>
<f:facet name="header" >
<h:outputText value="Picture"/>
</f:facet>
<h:outputText value="#{product.picture_url}"/>
</h:column>
</h:dataTable>The contents of the ArrayList are printed out fine.
I am now looking to iterate over the items to output a link
so far I have... but it doesn't seem to work
<c:forEach items="${ProductBean.productList}">
<h:form>
<h:commandLink action=images/"#{productList.picture_url}" title="#{productList.title}"><h:graphicImage url="thumbs/#{productList.picture_url}" width="100" height="75" alt="" /></h:commandLink>
</h:form>
</div>
</c:forEach>I think the problem lies with appending the "images/" before the url
Ideally I would like it to replicate the actual HTML view which is
<a href="images/london_flight.jpg" title="London in Flight"><img src="images/london_flight.jpg" width="100" height="75" alt="" /></a>If anyone could shed any light it would be much appreciated.
Thanks in advanceThanks that was helpful so I have modified my code to...
<c:forEach items="${ProductBean.productList}" var="product">
<div class="thumbnail">
<h:form>
<h:commandLink action="images/#{product.picture_url}" title="#{product.title}"><h:graphicImage url="thumbs/#{product.picture_url}" width="100" height="75" alt="" /></h:commandLink>
</h:form>
</div>
</c:forEach>But I seem to be getting a jsp error...
javax.el.ELException: Not a Valid Method Expression: images/#{product.picture_url}
How can I append "images/" to the action without it falling over.
Thanks -
Referencing beans as bean attributes in struts tags
Do struts tags allow you access bean attributes when the bean itself is an attribute of another bean?
If so, what would be the syntax?
For instance, I have bean A that contains as an attribute another bean B. I want to test for the value of
an attribute within B. Let's say I have bean A where A has get/set methods for B and B has get/set methods for an attribute called 'amount'. Then can I say something like:
<logic:equal name="A" property="B.amount" value="1">
I tried this syntax and also "B.getAmount()", but neither seems to work.
I have also tried <logic:equal name="A.B" property="amount" value="1">
but this doesn't work either.I've used that x.y syntax before in some tags, but I don't know if logic tags support it... you should be able to do this:
<bean:define id="B" name="A" property="B" />
<logic:equal name="B" property="amount" value="1"> -
Portal runtime error: Cannot access bean property
Dear all,
Does anybody have a clue what problem might couse the <b>Portal Runtime Error</b> described below?
It does seem to occur when a second user wants to access the <b>Component</b>.
<b>Portal Runtime Error</b>
An exception occurred while processing a request for :
iView : pcd:portal_content/com.xxxxx.luminaires/com.xxxx.iviews/Quotations/EasyQuote
<b>Component</b> Name : EasyQuoteDemo.EasyQuoteComponent
Tag tableView attribute model: Cannot access bean property quotationHeader.CurrentTableModel in page context.
Exception id: 04:50_21/09/04_0070
See the details for the exception ID in the log file
Thxs in advance
JoostHi Dominik,
Having a closer look at the problem, we found it is not the number of users.
It seems our JAVA components keeps the conenctions with SAP open and reopens a new one every time we start the component.
If we finished solving the problem, I will publish the solution.
Greetings,
Joost -
[JDev 10.1.2] Compare JSTL var attribute with sessionScoped bean attribute
I'm new to JSTL.
I'm looking for a way in JDev 10.1.2 to compare a sessionScope bean attribute (sessionScope.User.Username) and a JSTL attribute variable. For this purpose I've developed the following code:
+<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>+
+<%@ page import="bean.User"%>+
+<jsp:useBean id="User" class="bean.User" scope="session" />+
+...+
+<c:forEach var="Row" items="${bindings.ReadOnlyViewObject.rangeSet}">+
+<c:choose>+
+<c:when test="${Row.CreatedBy == sessionScope.User.Username}">+
+...+
+</c:when>+
+</c:choose>+
+</c:forEach>+
+...+
However it doesn't work on the test line. I'm not able to compare Row.CreatedBy to sessionScope.User.Username.
I've also tried <c:when test="${Row.CreatedBy == User.Username}"> without success.
Could you help me?
Thanks.The bean property will have an initial lowercase name, so try sessionScope.User.username ?
I believe since you used the jsp:useBean, that you can also just use User.username without the "sessionScope" in there, as well. -
Help:accessing beans method
hello
i have made one application in which i have made two beans under different packages. i am trying to access beans through jsp pages. i am able to access beans and their methods but when i add new method in bean and tried to access that method with different new jsp page say page1.jsp. I am not able to access new method though i am able to access old methods of same beans with this new jsp page. then i made new bean and copied that method in this new bean . then i tried to access that method of this new bean with page1.jsp and i am able to access it can any body guide me what is the reason for this. i want to run this method in old beran rather than new bean
my directory structure is:
projectlms---main folder
addstream---old jsp page
page1---new jsp page
web-inf/classes
com-------main packageof beans
ProgramManager----sub package of classes
bean1--------old bean
new bean------new bean just for testing
now the problem is that i want to add one more method to bean1 and want to access it through pag1.jsp
but i am not able to access it and same method when i take to new bean i am able to access that method through page1.jsp
but i am able to access old methods of bean1 through page1.jsp
thanks
regards
vivekCould be a caching issue.
Wipe out the COMPILED jsps and try again. -
How to access the hidden variable in jsp
hi all,
i need help to know how to access the hidden variable in the same jsp.
Following is the code snippet just have a look at that.
ArrayList arrRankingSummary = (java.util.ArrayList)session.getAttribute("arrRankingSummary");
<logic:iterate id="rankingSummary" name="arrRankingSummary">
<input type="hidden" name="allApplicantID" value='<bean:write name="rankingSummary" property="APPLICANTID"/>' />
<input type="hidden" name="allAdmissionRank" value='<bean:write name="rankingSummary" property="ADMISSIONRANK"/>' />
</logic:iterate>
<input type="hidden" name="applicantID" value='<bean:write name="rankingSummary" property="APPLICANTID"/>' />
<TD align=center><Input type=Text name="admissionRank" class=Textverysmall size=2 value='<bean:write name="rankingSummary" property="ADMISSIONRANK"/>' maxlength="10" /> </TD>
I want to remove the element from arraylist on these condition
if(allApplicantID.value ==applicantID.value){
arrRankingSummary .remove("admissionRank");
Now the pbm is i m not getting how to access the hidden variable in jsp or how to use the values of hidden variable for the condition.
Pls help me out.
Thanks in adv.
Regards,
Rituhi ram,
as i mentioned i m creating hidden variables & i m doing some validation on form submit.
The following is js code snippet for validation.
for (var i = 0; i < document.forms[0].admissionRank.length; i++)
admissionRank = document.forms[0].admissionRank.value;
for(var j = 0; j < document.forms[0].allAdmissionRank.length; j++)
//alert ("admissionRank : " + admissionRank + " document.forms[0].allAdmissionRank[" + j + "].value : " + document.forms[0].allAdmissionRank[j].value + "\ndocument.forms[0].allApplicantID[" + j + "].value : " + document.forms[0].allApplicantID[j].value + " document.forms[0].applicantID[" + i + "].value : " + document.forms[0].applicantID[i].value);
if(admissionRank == document.forms[0].allAdmissionRank[j].value && document.forms[0].allApplicantID[j].value != document.forms[0].applicantID[i].value && admissionRank != "" && document.forms[0].allAdmissionRank[j].value != "")
flag = false;
document.forms[0].admissionRank[i].focus();
document.forms[0].admissionRank[i].select();
break;
if (flag == false)
break;
In this validation i want admissionRank to be removed from the original arraylist if following condition gets satisfied
"(document.forms[0].allApplicantID[j].value == document.forms[0].applicantID[i].value )"
Thanks in adv
Ritu -
Unable to call bean method at second JSP.
I have a Bean called "Database" in that two methods
1.public String methodReturnsString()
2.public List methodReturnsList()
And also i have three jsp's.
1.First.jsp
2.Success.jsp
3.fail.jsp
i called methodReturnsString of "Database" in the First.jsp ,after receiving intended String from the method methodReturnsString() i.e "success" or "fail" i can goto Success.jsp. or fail.jsp.
Assume i got String "success" eventually leads me to Success.jsp , In this Success.jsp i was trying to access Bean method methodReturnsList() , Now the problem is I cant access the Bean method methodReturnsList() in Success.jsp, where i want to print the List that is returned by methodReturnsList().
Can anybody tell me what is the mistake i am doing.
here is "Success.jsp"
<%@ page contentType="text/html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
Login Successful
<html>
<f:view>
<h:form id="result">
<p>
<c:forEach var="x" items="${Database.methodWithList}" >
${x}
</c:forEach>
</p>
</h:form>
</f:view>
</html>here is" Faces-config.xml"
<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<managed-bean>
<managed-bean-name>Database</managed-bean-name>
<managed-bean-class>com.persistent.parashar.database.Database</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/First.jsp</from-view-id>
<navigation-case>
<from-action>#{Database.methodReturnsString}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/success.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{Database.methodReturnsString}</from-action>
<from-outcome>fail</from-outcome>
<to-view-id>/fail.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Here is Database.java
public class Database {
public List methodWithList()
System.out.println("Contents in the List#########");
List al=new ArrayList();
al.add("jaya");
al.add("chandra");
al.add("raheem");
al.add("balu");
System.out.println("Contents in the List"+al);
return al;
public String methodReturnsString()
return "success";
}Thank you for reply, after making few chages by taking your suggestion i am still struggling to get the desired result in my jsp. please into the code below
public class Database {
public List calToDatabase;
public static void initialCalToList()
System.out.println("Contents in the List#########");
List al=new ArrayList();
al.add("JAya");
al.add("chandra");
al.add("raheem");
al.add("balu");
System.out.println("Contents in the List"+al);
Database db= new Database();
db.setCalToDatabase(al); // calling the setter with list as an argument
public List getCalToDatabase() {
return calToDatabase;
public void setCalToDatabase(List calToDatabase) {
this.calToDatabase = calToDatabase;
}I have also made changes in success.jsp
<%@ page contentType="text/html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
Login Successful
<html>
<f:view>
<h:form id="result">
<p>
<c:forEach var="x" items="#{Database.getCalToDatabase}" >
${x}
</c:forEach>
</p>
</h:form>
</f:view>
</html> -
Access dynamic attributes BPM; error while activating the process in sxi
hi everybody,
I have to access dynamic attributs in a BPM condition. I thought I could achive this when I click the radiobutton "contextobject" in the condition editor.
When using the value-help button on the contextobject a huge list of objects is shown for selection.
Strange to me is that also the radionbutton "interface-variable" is checked. I can not uncheck this radiobutton. But this makes the error while activating:
"Containerelement 'IDOC_'MyContainerelement'{XSDSIMPLE::xsd:string;SHeaderSUBJECT:ht' does not exist".
Has anybody expirience using the dynamic attributes/contextobjekts in BPM?
Thanks, Regards MarioHi all,
it seems to be impossible to access the attributes:
Technical Context Object in ccBPM
Regards Mario -
How can I access the Attribute Values from the Search Region
Hi all,
I have a table which contains Company id, department id, and PositonId. For a particular Company and Department there may be multiple records.
I have to pupulate a table which contains the position and other details that comes under a particular Department and Position based on the selection in the Three comboBoxes.
Also I have to populate a select many Shuttle to add new postions and records under a particular Department.
I created a query panel *(Search Region)* for the serch and a table to display the data. That is working fine.
Now the issue is I am using a view criteria to populate the shuttle with two bind variables ie, DepartmentId and CompanyId.
If the serach will return a resuktant set in the table it will also pupulate the correct records, otherwise ie, if the if the serch result is empty the corresponding iterator and the attribute is setting as null.
SO I want to access the attribute values from the Search Region itsef to populate the shuttle.
I don't know how can I access the data from the Search Region.
Please Help.
Regards,
Ranjithyou could access the parameters entered in search region by the user as follows:
You can get handle to the value entered by the user using queryListener method in af:query.
You can intercept the values entered as described
public void onQueryList(QueryEvent queryEvent) {
// The generated QueryListener replaced by this method
//#{bindings.ImplicitViewCriteriaQuery.processQuery}
QueryDescriptor qdes = queryEvent.getDescriptor();
//get the name of the QueryCriteria
System.out.println("NAME "+qdes.getName());
List<Criterion> searchList = qdes.getConjunctionCriterion().getCriterionList();
for ( Criterion c : searchList) {
if (c instanceof AttributeCriterion ) {
AttributeCriterion a = (AttributeCriterion) c;
a.getValues();
for ( Object o : a.getValues()){
System.out.println(o.toString());
//call default Query Event
invokeQueryEventMethodExpression("#{bindings.ImplicitViewCriteriaQuery.processQuery}",queryEvent);
public void onQueryTable(QueryEvent queryEvent) {
// The generated QueryListener replaced by this method
//#{bindings.ImplicitViewCriteriaQuery.processQuery}
QueryDescriptor qdes = queryEvent.getDescriptor();
//get the name of the QueryCriteria
System.out.println("NAME "+qdes.getName());
invokeQueryEventMethodExpression("#{bindings.ImplicitViewCriteriaQuery.processQuery}",queryEvent);
private void invokeQueryEventMethodExpression(String expression, QueryEvent queryEvent){
FacesContext fctx = FacesContext.getCurrentInstance();
ELContext elctx = fctx.getELContext();
ExpressionFactory efactory = fctx.getApplication().getExpressionFactory();
MethodExpression me = efactory.createMethodExpression(elctx,expression, Object.class, new Class[]{QueryEvent.class});
me.invoke(elctx, new Object[]{queryEvent});
Thanks,
Navaneeth -
Problem with file access in other computer in jsp
I have problem with file accessing in other computer in jsp.
The follow code
File folder=new File("Z:"+File.separator+"sharefolder");//Z is a net share driver
File[] files=folder.listFiles();
System.out.println("test");
System.out.println("length="+files.length);
will throw exception at the second print.
but it works well in main funtion.
Is anybody know what is the problem.
JSP works on windows2003 server,tomcat 5.0.28 JDK1.4 net share folder on windows2000 serverno error code for this.But when I start tomcat I get the follow error.
java.lang.IllegalArgumentException: Document base Z:\ does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:138)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3910)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4138)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer.java:903)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:216)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:256)
at org.apache.commons.digester.Rule.end(Rule.java:276)
at org.apache.commons.digester.Digester.endElement(Digester.java:1058)
at org.apache.catalina.util.CatalinaDigester.endElement(CatalinaDigester.java:76)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1567)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:488)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:483)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)
Jun 5, 2006 6:55:41 PM org.apache.catalina.core.StandardContext start
SEVERE: Error in resourceStart()
Jun 5, 2006 6:55:41 PM org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
Jun 5, 2006 6:55:41 PM org.apache.catalina.core.StandardContext start
SEVERE: Context startup failed due to previous errors
Jun 5, 2006 6:55:41 PM org.apache.catalina.core.StandardContext start
SEVERE: Exception during cleanup after start failed
LifecycleException: Container StandardContext[msgstore] has not been started
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4466)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer.java:903)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:216)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:256)
at org.apache.commons.digester.Rule.end(Rule.java:276)
at org.apache.commons.digester.Digester.endElement(Digester.java:1058)
at org.apache.catalina.util.CatalinaDigester.endElement(CatalinaDigester.java:76)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1567)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:488)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:483)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287) -
How to access an attribute(this is referencing to another class) in a class
Dear Gurus,
I have to read an attribute of a class and that attributes type another class.
I have intantiated the class and my question is how to read the attribute. I know I can not dirrectly read the attribute since this is another class. I think I have to first reference the attribute right? Please advise me.
My code looks like below:
data: lo_fpm type ref to if_fpm.
data: lo_msg_mgr type ref to if_fpm_message_manager.
data: lo_component_manager type ref to cl_fpm_component_manager.
lo_fpm = cl_fpm_factory=>get_instance( ). " cl_fpm_factory is a class which has a static method get_instance
lo_msg_mgr = lo_fpm->mo_message_manager.
lo_component_manager = lo_fpm->mo_component_manager.
The above statement is giving syntax error. I do not know why.
The basic difference b/n the two methods is if_fpm~mo_message_manager type ref to if_fpm_message_manager and
mo_component_manager type ref to cl_fpm_component_manager.
Any help would be appreciated.
Thanks,
GSMHello
I cannot test the following coding because I do not get the singleton instance yet it should work:
*& Report ZUS_SDN_CL_FPM_FACTORY
*& Thread: How to access an attribute(this is referencing to another class) in a class
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1398429"></a>
REPORT zus_sdn_cl_fpm_factory.
DATA: go_fpm TYPE REF TO cl_fpm. " class implements if_fpm.
DATA: go_msg_mgr TYPE REF TO if_fpm_message_manager.
DATA: go_component_manager TYPE REF TO cl_fpm_component_manager.
START-OF-SELECTION.
BREAK-POINT.
go_fpm ?= cl_fpm_factory=>get_instance( ). " cl_fpm_factory is a class which has a static method get_instance
CHECK ( go_fpm IS BOUND ).
go_msg_mgr = go_fpm->mo_message_manager.
go_component_manager = go_fpm->mo_component_manager.
END-OF-SELECTION.
Regards
Uwe
Maybe you are looking for
-
How do I organise a photo show in file order?
I'm trying to import a load of photos into a movie I'm making. I've named them all so they stack in the correct order, but Premier 8 seems insistant on putting them in date order, which is no good for my purposes. How do I get it to put them into the
-
Is there a way to stop receiving my text messages on both of my devices? I have an ipad air and an iphone. People text my phone number and it goes to my phone and the ipad, but this only started happening when I upgraded from the original ipad to the
-
Lens Profiles not working in Lightroom 5.4?
I've got OSX 10.9.2, Lightroom 5.4, latest Camera raw, everything up to date. When I "Enable Profile Corrections" for an image shot with a Sony a7r and Sony FE 55mm lens, it should automatically retrieve this profile: /Library/Application Support/A
-
What happens here and how does it all work?
ok so lets say i have 3 things running: 1 model (obejct A) 2 objects (B and C) which update model A at random intervals ok so lets say B tells A to update(params). this update takes a long time to finish, meanwhile C asks A getInfo() which returns th
-
Transparency Issue when exporting Image Sequence
Hi, I'm creating short anims which have transparency and exporting them as png image sequences. I'm finding two issues with the export though: 1) The first frame is always solid black (when it should be totally transparent) 2) The R,G,B channels o