1. " ..... when you try to display a bean property in your JSP you're not seeing the
value you expect in the browser."
Yes, I set the bean value in execute() method and I am trying to get that
display in JSP result page.
2. "You also submit a form, and you might mean that the form isn't being handled in
the way you ...."
My form have just have a single button which just trigger the action.
3. " .. but show nothing that actually puts a bean into the session. So far, your
problem is there."
I also think that I am missing something to relate between bean in action and
JSP page.
4. " ... is there a reason you're learning Struts 1?"
I am working ont his app developed in struts 1 so try to fix around. Soon I
will be moving to Struts 2.
So what will be the solution to issue #3?
Thanks
Anjib
On 1/28/2011 9:59 AM, Dave Newton wrote:
On Fri, Jan 28, 2011 at 9:50 AM, Anjib Mulepati wrote:
Can anyone help to get this simple program run?
I suspect you mean "run correctly".
When I run this app I get null as result.
When describing a problem it's helpful to be specific: while reading the
code leads me to *believe* what you mean is that when you try to display a
bean property in your JSP you're not seeing the value you expect in the
browser.
But I really have no idea if that assumption is correct. You also submit a
form, and you might mean that the form isn't being handled in the way you
expect (although you've done, or at least shown, nothing related to Struts 1
form processing at all).
So.
You're attempting to display a bean value retrieved from the session, but
show nothing that actually puts a bean into the session. So far, your
problem is there.
You'll be disappointed when you find out all you have to do to process forms
in the normal Struts 1 way... is there a reason you're learning Struts 1?
Most new development has moved on to more recent frameworks, with good
reasons. I'm suspicious of companies doing new development in Struts 1.
Dave
On 1/27/2011 4:37 PM, Anjib Mulepati wrote:
1. JSP Files
=========
a) Calling page
---------------------
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<html:html lang="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><bean:message key="welcome.title"/></title>
</head>
<body style="background-color: white">
<form action="getValue.do" method="post">
<input type="submit" value="Get Value" />
</form>
</body>
</html:html>
b) Result Page
-------------------
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>result</h1>
<jsp:useBean id="exchangeBean" scope="session"
class="com.anjib.beans.DataBean" />
<jsp:getProperty name="exchangeBean" property="sampleProperty" />
</body>
</html>
2. Bean Class
===========
package com.anjib.beans;
import java.io.Serializable;
public class DataBean implements Serializable {
private String sampleProperty;
public DataBean() {
}
public String getSampleProperty() {
return sampleProperty;
}
public void setSampleProperty(String value) {
this.sampleProperty = value;
}
}
3. Action Class
============
package com.anjib.actions;
import com.anjib.beans.DataBean;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class GetValueAction extends org.apache.struts.action.Action {
private static final String SUCCESS = "success";
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
DataBean myBean = new DataBean();
myBean.setSampleProperty("Anjib");
System.out.println("Bean Value: " + myBean.getSampleProperty());
return mapping.findForward(SUCCESS);
}
}
When I run this app I get null as result.
On 1/27/2011 4:16 PM, Anjib Mulepati wrote:
Hi All,
I am looking for the simple example of using beans and tag in Struts to
avoid using scriptlets. I am trying to get concept of using tag to access
result from back end using the beans. It will be very helpful if some one
can provide me a link or example which I can look into.
Thanks
Anjib
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org