You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bryan Field-Elliot <br...@netmeme.org> on 2001/12/19 17:13:42 UTC

Programming Style, Custom Tags - Opinions?

Hi all,

I wanted to collect a few opinions on programming style with respect to
Struts and JSP.

The following have been my guiding principles for the last several
Struts projects I've done:

1. When a JSP page needs to ALTER the model (e.g. data will be written),
a Struts Action should be used.

2. When a JSP page needs to RENDER the model (e.g. read data, and
transform it into HTML), a JSP custom tag should be used to "get" the
data into a local (scriptable) variable/bean.

Over time, this strategy produces a roughly 1:1 ratio of Actions to
Custom Tags. Sometimes there's even a gray area concerning where to put
the logic -- e.g. if the very act of reading data will produce a log
entry, technically that's writing to the model -- however, I tend to put
"primarily read" operations into custom tags.

One reason why I do this, is so that the Actions don't necessarily have
to know every single kind of model data the resulting JSP page may want
to draw from. I leave it up to the JSP page to decide.

A drawback is that you end up with so much code in both camps -- it
would be nice if all the code could, for example, extend the same base
classes, or something.

I'd appreciate hearing some opinions on whether or not others have found
this style workable, and if not, then what works better.

Thanks,

Bryan


Re: DTDS Required for Struts and Web Application.

Posted by Keith Bacon <ke...@yahoo.com>.
I can't find it on the struts site but i think it's
Under definition
  <servlet>
    <servlet-name>action</servlet-name>

This bit - change it to false. Try it out - sorry if it's not.

    <init-param>
      <param-name>validate</param-name>
      <param-value>true</param-value>
    </init-param>

--- "Sudhir S. Shetty" <ss...@powershare.net> wrote:
> How exactly should i do it can you give me an example.
> regards,
> Sudhir
> 
> ----- Original Message -----
> From: "Ted Husted" <hu...@apache.org>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, February 04, 2002 18:18
> Subject: Re: DTDS Required for Struts and Web Application.
> 
> 
> > It's suppose to use the one's in the Struts JARs. Under some
> > circumstances, from what people say, that doesn't seem to happen.
> >
> > There is a switch in the ActionServlet ("validating") that can turn the
> > DTD validation off if it gets to be a problem.
> >
> >
> http://jakarta.apache.org/struts/api-1.0/org/apache/struts/action/ActionServ
> let.html
> >
> > -- Ted Husted, Husted dot Com, Fairport NY USA.
> > -- Java Web Development with Struts.
> > -- Tel +1 585 737-3463.
> > -- Web http://www.husted.com/struts/
> >
> >
> >
> > "Sudhir S. Shetty" wrote:
> > >
> > > Hi All,
> > >           I have an Intranet application hosted on Weblogic Server , the
> > > application is built on STRUTS, I need to know, whenever I start up
> > > weblogic, the server downloads the DTD's for the application i.e. the
> struts
> > > specific DTD's and the ones specific to Sun for the Web application.
> > > Can You suggest me a work arond in which I download the DTD's on to my
> > > machine on to a folder, so that These DTD's dont need to be downloaded
> > > everytime I start Weblogic up.
> > > Kindly tell me the places I have to make the change.
> > >
> > > Thanks in advance,
> > > Sudhir
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: DTDS Required for Struts and Web Application.

Posted by "Sudhir S. Shetty" <ss...@powershare.net>.
How exactly should i do it can you give me an example.
regards,
Sudhir

----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 04, 2002 18:18
Subject: Re: DTDS Required for Struts and Web Application.


> It's suppose to use the one's in the Struts JARs. Under some
> circumstances, from what people say, that doesn't seem to happen.
>
> There is a switch in the ActionServlet ("validating") that can turn the
> DTD validation off if it gets to be a problem.
>
>
http://jakarta.apache.org/struts/api-1.0/org/apache/struts/action/ActionServ
let.html
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Java Web Development with Struts.
> -- Tel +1 585 737-3463.
> -- Web http://www.husted.com/struts/
>
>
>
> "Sudhir S. Shetty" wrote:
> >
> > Hi All,
> >           I have an Intranet application hosted on Weblogic Server , the
> > application is built on STRUTS, I need to know, whenever I start up
> > weblogic, the server downloads the DTD's for the application i.e. the
struts
> > specific DTD's and the ones specific to Sun for the Web application.
> > Can You suggest me a work arond in which I download the DTD's on to my
> > machine on to a folder, so that These DTD's dont need to be downloaded
> > everytime I start Weblogic up.
> > Kindly tell me the places I have to make the change.
> >
> > Thanks in advance,
> > Sudhir
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: DTDS Required for Struts and Web Application.

Posted by Ted Husted <hu...@apache.org>.
It's suppose to use the one's in the Struts JARs. Under some
circumstances, from what people say, that doesn't seem to happen. 

There is a switch in the ActionServlet ("validating") that can turn the
DTD validation off if it gets to be a problem. 

http://jakarta.apache.org/struts/api-1.0/org/apache/struts/action/ActionServlet.html

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/



"Sudhir S. Shetty" wrote:
> 
> Hi All,
>           I have an Intranet application hosted on Weblogic Server , the
> application is built on STRUTS, I need to know, whenever I start up
> weblogic, the server downloads the DTD's for the application i.e. the struts
> specific DTD's and the ones specific to Sun for the Web application.
> Can You suggest me a work arond in which I download the DTD's on to my
> machine on to a folder, so that These DTD's dont need to be downloaded
> everytime I start Weblogic up.
> Kindly tell me the places I have to make the change.
> 
> Thanks in advance,
> Sudhir
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cannot find tag library

Posted by Elijah Jacobs <el...@hotmail.com>.
Thanks Max,

that worked great.

- ej
----- Original Message -----
From: "Max Cooper" <ma...@maxcooper.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 04, 2002 3:34 PM
Subject: Re: cannot find tag library


> Elijah,
>
> Try giving your tag handler class a proper package name and put that in
the
> app.tld file.
>
> -Max
>
> ----- Original Message -----
> From: "Elijah Jacobs" <el...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, February 04, 2002 8:33 AM
> Subject: cannot find tag library
>
>
> > Hi all,
> >
> > I am using Tomcat 4.01; Windows 2000 ; Struts v1.0
> >
> > I created a tag which displays a message on the screen.  I followed the
> > basic layout of the example that came with struts.  by "layout" I mean:
> >
> > 1. I created a tag under the /classes directory.  this time I put it
right
> > under the /classes directory so I didn't need to deal with package
names.
> > 2. I added the tag in the app.tld (which is right under /web-inf)
> > 3. On my jsp page, I reference the TLD file and gave it a prefix "app"
> (just
> > like the example).
> >     <%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>
> >
> >
> > when I do " <app:hello /> " in my JSP page (Bid.jsp) I get:
> >
> > Generated servlet error:
> > C:\Program Files\Apache Tomcat
4.0\work\localhost\blank\bid$jsp.java:143:
> > Class org.apache.jsp.HelloTag not found.
> >                   HelloTag _jspx_th_app_hello_0 = new HelloTag();
> >                   ^
> >
> > I am not sure why it's looking for my HelloTag under org.apache.jsp when
I
> > put it on the /classes directory.  I have other Java files right under
the
> > /classes directory and Tomcat 4.0.1 was able to find them - although
they
> > were not custom tag file, but that shouldn't matter, right?
> >
> > thanks in advance,
> > - ej -
> (SNIP)
>
>
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.o
rg>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cannot find tag library

Posted by Max Cooper <ma...@maxcooper.com>.
Elijah,

Try giving your tag handler class a proper package name and put that in the
app.tld file.

-Max

----- Original Message -----
From: "Elijah Jacobs" <el...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 04, 2002 8:33 AM
Subject: cannot find tag library


> Hi all,
>
> I am using Tomcat 4.01; Windows 2000 ; Struts v1.0
>
> I created a tag which displays a message on the screen.  I followed the
> basic layout of the example that came with struts.  by "layout" I mean:
>
> 1. I created a tag under the /classes directory.  this time I put it right
> under the /classes directory so I didn't need to deal with package names.
> 2. I added the tag in the app.tld (which is right under /web-inf)
> 3. On my jsp page, I reference the TLD file and gave it a prefix "app"
(just
> like the example).
>     <%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>
>
>
> when I do " <app:hello /> " in my JSP page (Bid.jsp) I get:
>
> Generated servlet error:
> C:\Program Files\Apache Tomcat 4.0\work\localhost\blank\bid$jsp.java:143:
> Class org.apache.jsp.HelloTag not found.
>                   HelloTag _jspx_th_app_hello_0 = new HelloTag();
>                   ^
>
> I am not sure why it's looking for my HelloTag under org.apache.jsp when I
> put it on the /classes directory.  I have other Java files right under the
> /classes directory and Tomcat 4.0.1 was able to find them - although they
> were not custom tag file, but that shouldn't matter, right?
>
> thanks in advance,
> - ej -
(SNIP)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


cannot find tag library

Posted by Elijah Jacobs <el...@hotmail.com>.
Hi all,

I am using Tomcat 4.01; Windows 2000 ; Struts v1.0

I created a tag which displays a message on the screen.  I followed the
basic layout of the example that came with struts.  by "layout" I mean:

1. I created a tag under the /classes directory.  this time I put it right
under the /classes directory so I didn't need to deal with package names.
2. I added the tag in the app.tld (which is right under /web-inf)
3. On my jsp page, I reference the TLD file and gave it a prefix "app" (just
like the example).
    <%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>


when I do " <app:hello /> " in my JSP page (Bid.jsp) I get:

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\blank\bid$jsp.java:143:
Class org.apache.jsp.HelloTag not found.
                  HelloTag _jspx_th_app_hello_0 = new HelloTag();
                  ^

I am not sure why it's looking for my HelloTag under org.apache.jsp when I
put it on the /classes directory.  I have other Java files right under the
/classes directory and Tomcat 4.0.1 was able to find them - although they
were not custom tag file, but that shouldn't matter, right?

thanks in advance,
- ej -

p.s. below are parts my app.tld and web.xml files and the rest of the error:
========    app.tld ================
  <tag>
    <name>hello</name>
    <tagclass>HelloTag</tagclass>
    <bodycontent>empty</bodycontent>
  </tag>

========    web.xml ================
  <taglib>
    <taglib-uri>/WEB-INF/app.tld</taglib-uri>
    <taglib-location>/WEB-INF/app.tld</taglib-location>
  </taglib>

========    error message ================

type Exception report

message Internal Server Error

description The server encountered an internal error (Internal Server Error)
that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 14 in the jsp file: /bid.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\blank\bid$jsp.java:143:
Class org.apache.jsp.HelloTag not found.
                  HelloTag _jspx_th_app_hello_0 = new HelloTag();
                  ^


An error occurred at line: 14 in the jsp file: /bid.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\blank\bid$jsp.java:143:
Class org.apache.jsp.HelloTag not found.
                  HelloTag _jspx_th_app_hello_0 = new HelloTag();
                                                      ^
2 errors

	at org.apache.jasper.compiler.Compiler.compile(Compiler.java, Compiled
Code)
	at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
	at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspSe
rvlet.java:177)
	at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:189)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java, Compiled
Code)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:243)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:201)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java,
Compiled Code)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java,
Compiled Code)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:163)
	at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java,
Compiled Code)
	at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java,
Compiled Code)
	at java.lang.Thread.run(Thread.java:479)



----------------------------------------------------------------------------
----


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: DTDS Required for Struts and Web Application.

Posted by Christian Bouessay <cb...@businessdecision.com>.
Sudhir S. Shetty wrote:

> Hi All,
>           I have an Intranet application hosted on Weblogic Server , the
> application is built on STRUTS, I need to know, whenever I start up
> weblogic, the server downloads the DTD's for the application i.e. the struts
> specific DTD's and the ones specific to Sun for the Web application.
> Can You suggest me a work arond in which I download the DTD's on to my
> machine on to a folder, so that These DTD's dont need to be downloaded
> everytime I start Weblogic up.


Try to copy DTD files in the directory:

org/apache/struts/resources

This directory doesn't exist in src distrib, but is present in the .jar 
file.

It works for me.

--
C. Bouessay






--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


DTDS Required for Struts and Web Application.

Posted by "Sudhir S. Shetty" <ss...@powershare.net>.
Hi All,
          I have an Intranet application hosted on Weblogic Server , the
application is built on STRUTS, I need to know, whenever I start up
weblogic, the server downloads the DTD's for the application i.e. the struts
specific DTD's and the ones specific to Sun for the Web application.
Can You suggest me a work arond in which I download the DTD's on to my
machine on to a folder, so that These DTD's dont need to be downloaded
everytime I start Weblogic up.
Kindly tell me the places I have to make the change.

Thanks in advance,
Sudhir


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: No Of rows in a Table

Posted by Anand Belaguly <an...@edgesoftinc.com>.
Check this out..it works well

http://jsptags.com/tags/navigation/pager/

Anand

-----Original Message-----
From: Sudhir S. Shetty [mailto:sshetty@powershare.net]
Sent: Sunday, June 09, 2002 11:48 PM
To: Struts Users Mailing List
Subject: No Of rows in a Table


Hi Everybody,
                       I have a rquirement in which I have a Table
displayed, For this I retrieve The table rows from the database, But the
table should just list the first 20 records, a functionality should be
proivided via which on clicking the NExt Button the user is displayed the
next 20 records and so on, I would be greatful if you could provide me with
adequate resources for it.
Thanks in advance,
Sudhir


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


No Of rows in a Table

Posted by "Sudhir S. Shetty" <ss...@powershare.net>.
Hi Everybody,
                       I have a rquirement in which I have a Table
displayed, For this I retrieve The table rows from the database, But the
table should just list the first 20 records, a functionality should be
proivided via which on clicking the NExt Button the user is displayed the
next 20 records and so on, I would be greatful if you could provide me with
adequate resources for it.
Thanks in advance,
Sudhir


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Programming Style, Custom Tags - Opinions?

Posted by Bryan Field-Elliot <br...@netmeme.org>.
Thanks again Ted,

I didn't mean to imply that my View developers were also developing
their own Tags. They aren't. Instead, I develop the Model, which
includes back-tier business logic to perform actions, and return a bean
(or a collection of beans) as a result. High-level business method names
like:

postMessage
deleteMessage
getMessageByID
getMessagesByTopic
getUserByID
getUsersByGroup
getLogEntriesByUser

Then, my Struts actions delegate all of their "real" work to these
back-tier business methods, and in many cases, put the resulting bean
(or bean collection) straight into the Request scope and forward on out
to a JSP page.

In terms of this model-rendering discussion, however -- I also tend to
implement JSP custom tags which call out to these same business methods
-- usually the "getXXX" variety, and almost never any other kind (in
other words, only those methods which *read* the model).

In that way, the View (JSP developers) can render the beans returned by
the preceeding Action, and anything else they darn well please, by way
of my published JSP Tag library (which is just a mirror of all my
model-tier's "getXXX" methods).

Now that I've fully explained my methodology, let me say that I am with
you that perhaps this is coupled tightly to the Model (although not at
all to the Controller). Where I don't follow you is how there's any
other way (e.g. your Layered pattern) to achieve the same results.

Perhaps what you're saying between the lines, is that rather than
implement custom tags, I should be implementing more "smarter JavaBeans"
which can navigate the model. You're right that this reduces my
dependency on JSP tags, and opens the door to other presentation engines
like Velocity. I think I'd like to give that a try. Historically,
virtually 100% of my JavaBeans have been simple Value Objects, composed
of nothing but properties, getters, and setters.

So let's assume that, for the benefit of the View, the model-reading
methods I was previously wrapping into JSP tags I will now wrap into
smarter JavaBeans (to be navigated by way of Struts or JSPTL tags).
Moving forward, then, do you think it's a bad idea to give them
model-specific JavaBeans, or should I seek to wrap up my model in
generic, non-specific collections of properties, which I am guessing is
similar to your ContextHelper class (or Craig's new DynaBean, which I am
eager to work with)?

Thanks for this great discussion,

Bryan





Struts Getting called Twice: Threading Problem?

Posted by "L. Yeung" <l_...@yahoo.com>.
hi! i'm experiencing my weird behavior from my webapp.
whenever i incoke some action, the methods were called
twice.

does this have to do with struts and multi-threading
issue?

com.ir.app.augustus.exception.GeneralFailureException:
Index: 12, Size: 12
        at
com.ir.app.augustus.control.POWebImpl.commitPurchaseOrder(POWebImpl.java:1298)
        at
com.ir.app.augustus.control.POWebImpl.commitPurchaseOrders(POWebImpl.java:1509)
        at
com.ir.app.augustus.action.po.POSummaryAction.commitPOs(POSummaryAction.java:195)
        at
com.ir.app.augustus.action.po.POSummaryAction.perform(POSummaryAction.java:46)
        at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1720)
        at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1519)
        at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:505)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown
Source)

        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown
Source)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at
org.apache.catalina.core.ContainerBase.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardContextValve.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at
org.apache.catalina.core.ContainerBase.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardContext.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardHostValve.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at
org.apache.catalina.valves.AccessLogValve.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at
org.apache.catalina.core.ContainerBase.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardEngineValve.invoke(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at
org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at
org.apache.catalina.core.ContainerBase.invoke(Unknown
Source)
        at
org.apache.catalina.connector.http.HttpProcessor.process(Unknown
Source)
        at
org.apache.catalina.connector.http.HttpProcessor.run(Unknown
Source)
        at java.lang.Thread.run(Thread.java:484)


thanks in advance.

l. yeung

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Programming Style, Custom Tags - Opinions?

Posted by Ted Husted <hu...@apache.org>.
Bryan Field-Elliot wrote:
> This is where I am having a problem -- if the Action is always
> responsible for creating whatever JavaBeans the View needs, then doesn't
> that unnecessarily couple (tightly) the View and the Controller? 

Personally, I advocate the Layers pattern for web applications, rather
than the Smalltalk MVC paradigm. 

In a layered application, the controller stands between the view and
model. The view can interact with the controller, and the controller can
interact with the model, but the view does not interact with the model,
since they are not on adjacent layers. In this approach, the model
itself is also layered, so that there is a business layer (API), an
interface layer (JDBC), and a resource layer (DBMS). 

I would say that the controller provides the information and the view
renders it. If the view needs more information, then yes, the controller
API needs to be extended, so that it provides the correct and complete
information. In a layered application, that is the controller's job.
Personally, I like to give objects (or people) a job, and then let them
do it. 



> suddenly, the View programmers decide they not only need to render the
> current user's Name, but also now need to start rendering the last five
> log entries for a user (on a particular JSP page), then they have to go
> back to the Action developer and ask for those additional beans to be
> stuffed into the scope.

If the View programmers are smart enough to write custom tags, then they
should also be able to work on their own Actions. Most often, the View
designers are not trained in writing custom tags, so it then becomes a
matter of whether the Java developers are writing custom tags or
JavaBeans that can be exposed by standard tag extensions. 

If the customization is made to the JavaBeans, rather than the tags,
then the information is available to any presentation system that can
access a JavaBean, not just JSPs in a Web application. General purpose
tags, like those in the Struts distribution, and also be used to access
the new JavaBeans, so that the view designers do not have yet another
tag to deal with.

It's possible that in your scenario things might need to be moved up a
rung. Perhaps some of what is now in the Actions belong in business
layer classes to be handled by the current "Action developers". Anyone
clever enought to write a custom tag should be able to handle an Action,
if there is a business layer API to back it up. It's possible that much
of what is now going into custom tags could be just as easily moved into
an Action.

 
> The approach I was arguing for makes it much more loosely coupled -- the
> Action just does it's work, and the View just renders whatever it feels
> it needs to render. 

I would venture that it actually increases coupling. Instead of the view
being coupled to the controller and the controller being coupled to the
model, all three are coupled to each other. Any change to the model
affects all three layers. Smalltalk MVC got away with this sort of
thing, but that strategy doesn't work as well for remote applications
that connect with distributed data systems.



> Of course, it makes sense for the Action to stuff a
> bean into a scope to communicate it's own activity results; however,
> general "model rendering" info isn't being plugged in by the Action;
> instead, the View (JSP pages) request them as they see fit.

I would say that it is the Action's job to provide the View with
whatever data it needs. As far as the View is concerned, the JavaBeans
in the servlet contexts are the model. This way real changes to the real
Model do not need to affect the View directly. The Action can be an
adapter between the business-tier data systems and the View. This
reduces overall coupling, since signficant changes can take place in the
Model without the View knowing the difference.



> I think this looser coupling makes for a much more manageable (less
> ripple-effect) design. However, a by-product of it, is the ballooning of
> custom JSP tags so that the View can get at the model, which I am having
> a problem with, and for which I was soliticing alternative perspectives.

It seems to me that code that accesses the model is being duplicated
between the custom tags and the Actions, and that would become a
maintenance burden over time. The tags are being tightly bound to the
business or resource tiers, which violates the Layers pattern. A symptom
of this is the code ballooning. 

Also, from a practical standpoint, the services (like Jasper) that
render the JSP custom tags write some god-awful code. The less you put
into tag extensions, or scriplets, or any kind of programming in the
View, the better. 

When the effort goes into JavaBeans that are passed to view, the
resulting code is not only more efficient, but these beans become
available to any presentation system in any environment that may come
down the pipeline. For example, it is very easy to turn a JavaBean into
an XML document that another system in the enterprise can use.

Case in point: several of the Struts tags now access the framework's
"model", and we have found that to be problematic. Accordingly, we have
recently added a ContextHelper JavaBean to the framework. We're in the
process of moving code that accessed the framework model into the
ContextHelper. When we are done, the tags will get whatever they need
from the ContextHelper instead of from the Struts model directly. 

As a result, we will have decoupled the tag extensions from a particular
ActionServlet implementation. We could start using multiple
ActionServlets, or entirely different controllers, so long as they pass
a ContextHelper along to the presentation layer. 

This initiative also decouples Struts from the tag extensions, and makes
it easy to use with other presentation systems, like Velocity templates.
Since the ContextHelper provides the same utility as the tags, any
presentation system that can access a JavaBean can lookup up hyperlinks
and localized messages, and other services the framework provides. 

Moving forward, this will also reduce maintenance, since maintaining the
ContextHelper, a plain Java class, is much simpler than routing around
in custom tag code, which can be difficult to factor properly.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Programming Style, Custom Tags - Opinions?

Posted by Bryan Field-Elliot <br...@netmeme.org>.
Thanks for the long opinion Ted. I agree with most of what you
discussed, which is that the Actions should be delegating to a "real"
business layer of back-end classes and methods, which can be re-applied
to a non-Struts front-end.

It's your first paragraph which I'd like to continue to discuss (and
which was in reference to my original topic of discussion):

On Fri, 2001-12-21 at 15:15, Ted Husted wrote:

    Personally, I would suggest that an Action should always be used to
    create whatever JavaBean helpers the view needs. The views only
    responsiblity should be to render the beans. Where these beans come-from
    or go-to is the controller's business. 
    
    This puts all the business logic behind Actions, and lets the
    presentation layer focus on rendering the presentation without knowing
    anything about the model. In the case of JavaServer Pages, it also makes
    it much easier to use standard tags, like those that ship with Struts,
    rather than having to write your own. This will be even more
    advantageous when JSPTL is finalized. 
    

This is where I am having a problem -- if the Action is always
responsible for creating whatever JavaBeans the View needs, then doesn't
that unnecessarily couple (tightly) the View and the Controller? If,
suddenly, the View programmers decide they not only need to render the
current user's Name, but also now need to start rendering the last five
log entries for a user (on a particular JSP page), then they have to go
back to the Action developer and ask for those additional beans to be
stuffed into the scope.

The approach I was arguing for makes it much more loosely coupled -- the
Action just does it's work, and the View just renders whatever it feels
it needs to render. Of course, it makes sense for the Action to stuff a
bean into a scope to communicate it's own activity results; however,
general "model rendering" info isn't being plugged in by the Action;
instead, the View (JSP pages) request them as they see fit.

I think this looser coupling makes for a much more manageable (less
ripple-effect) design. However, a by-product of it, is the ballooning of
custom JSP tags so that the View can get at the model, which I am having
a problem with, and for which I was soliticing alternative perspectives.

Bryan


Struts-Layout Error: Need Help

Posted by "L. Yeung" <l_...@yahoo.com>.
Hi I'm a newbie in Struts-Layout.
I got this error when i deployed it in Tomcat-4.0

javax.servlet.ServletException: try to access method
org.apache.struts.action.ActionForm.getServlet()Lorg/apache/struts/action/ActionServlet;
from class fr.improve.struts.taglib.layout.FormTag

Thanks in advance.
L. Yeung

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Programming Style, Custom Tags - Opinions?

Posted by Ted Husted <hu...@apache.org>.
Personally, I would suggest that an Action should always be used to
create whatever JavaBean helpers the view needs. The views only
responsiblity should be to render the beans. Where these beans come-from
or go-to is the controller's business. 

This puts all the business logic behind Actions, and lets the
presentation layer focus on rendering the presentation without knowing
anything about the model. In the case of JavaServer Pages, it also makes
it much easier to use standard tags, like those that ship with Struts,
rather than having to write your own. This will be even more
advantageous when JSPTL is finalized. 

A very important consideration, that has landed on more than one Struts
developers lap, is what happens when management want to do the same
thing, but without JavaServer Pages, or even a browser? If a lot of your
application's smarts is trapped in Actions or JavaServer Pages, meaning
the business layer has been mixed with the presentation layer, you're
sunk. If not, you're half-way home.

In a layered application, the real work should happen on the business
tier, which is not connected to an Action or JavaServer Page. It is very
tempting to put this code into an Action, but experience tells us it
should be in its own class where others can use it too. (Even if the
others are not on the horizon yet.) 

The amount of work involved is trival, and really should be a routine
refactoring anyway. If your peform method won't fit on the screen, or
has blocks that need comments, it's probably too long. And once you
start breaking up a multi-threaded perform into helper methods, it's
just as easy to put them in their own class. 

The Action can then call a business method which talks to the model, and
returns a value object or other helper. The Action makes that helper
available to the presentation layer, usually as a JavaBean. Then, all
the presentation layer has to do is render the data -- without having
the faintest idea of where it came from. Basically, a glorified
mail-merge job.

This also makes it easier to switch presentation layers later. For
example, it's now easy to use Velocity templates with Struts along with
JavaServer Pages. Documentation is pending, but here's a sample
application showing how the Velocity template thing works: 

http://husted.com/struts/resources.htm#new

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/


Bryan Field-Elliot wrote:
> 
> Hi all,
> 
> I wanted to collect a few opinions on programming style with respect to
> Struts and JSP.
> 
> The following have been my guiding principles for the last several
> Struts projects I've done:
> 
> 1. When a JSP page needs to ALTER the model (e.g. data will be written),
> a Struts Action should be used.
> 
> 2. When a JSP page needs to RENDER the model (e.g. read data, and
> transform it into HTML), a JSP custom tag should be used to "get" the
> data into a local (scriptable) variable/bean.
> 
> Over time, this strategy produces a roughly 1:1 ratio of Actions to
> Custom Tags. Sometimes there's even a gray area concerning where to put
> the logic -- e.g. if the very act of reading data will produce a log
> entry, technically that's writing to the model -- however, I tend to put
> "primarily read" operations into custom tags.
> 
> One reason why I do this, is so that the Actions don't necessarily have
> to know every single kind of model data the resulting JSP page may want
> to draw from. I leave it up to the JSP page to decide.
> 
> A drawback is that you end up with so much code in both camps -- it
> would be nice if all the code could, for example, extend the same base
> classes, or something.
> 
> I'd appreciate hearing some opinions on whether or not others have found
> this style workable, and if not, then what works better.
> 
> Thanks,
> 
> Bryan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: HOW DO YOU ADD DYNAMIC CONTENT VIA SCRIPTLETS IN HTML TAGS

Posted by Jin Bal <ji...@hotmail.com>.
<html:text property="companyName" value="<%=rs.getString(1);%>

try removing the semi-colon from the scriptlet (;) as you are using the <%=
construct.
regards
Jin
----- Original Message -----
From: "Sudhir S. Shetty" <ss...@powershare.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, December 24, 2001 10:40 AM
Subject: HOW DO YOU ADD DYNAMIC CONTENT VIA SCRIPTLETS IN HTML TAGS


> Hi Evrybody,
>                    Id like to know how to add dynamic content retrieved
via
> JSP scriplets to the HTMl tags
> I'll give you an example
> <html:text property="companyName" value="<%=rs.getString(1);%>
> When I give this tag nothing is displayed.
> Can you suggest me the syntax.
> Thanks in advance
> regards,
> Sudhir
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: HOW DO YOU ADD DYNAMIC CONTENT VIA SCRIPTLETS IN HTML TAGS

Posted by Prateek Paliwal <pr...@yahoo.com>.
If the resultSet (rs) is unavailable in the request or the
session scope it will display nothing. Also, struts cheks the
form-bean def from your config file to find out which ActionForm
to use (for the current action-mapping) and picks this out of
request / session scope (if available) to populate the form that
is being displayed in your JSP. 

Wrap the data that you wish to display from the result set into
action form to do this. Read the users guide
(http://jakarta.apache.org/struts/userGuide/index.html) on how
to do this. 

-- Prateek


--- "Sudhir S. Shetty" <ss...@powershare.net> wrote:
> Hi Evrybody,
>                    Id like to know how to add dynamic content
> retrieved via
> JSP scriplets to the HTMl tags
> I'll give you an example
> <html:text property="companyName" value="<%=rs.getString(1);%>
> When I give this tag nothing is displayed.
> Can you suggest me the syntax.
> Thanks in advance
> regards,
> Sudhir
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


HOW DO YOU ADD DYNAMIC CONTENT VIA SCRIPTLETS IN HTML TAGS

Posted by "Sudhir S. Shetty" <ss...@powershare.net>.
Hi Evrybody,
                   Id like to know how to add dynamic content retrieved via
JSP scriplets to the HTMl tags
I'll give you an example
<html:text property="companyName" value="<%=rs.getString(1);%>
When I give this tag nothing is displayed.
Can you suggest me the syntax.
Thanks in advance
regards,
Sudhir


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>