Re: AW: AW: action-mapping: why must the action-Attribute path be equivalent to the name of the jsp?

2001-08-05 Thread John Yu

Thanks for the explanation, Craig.
--
John
At 02:13 PM 8/5/2001 -0700, you wrote:
> 
> Oh, I see. That's what the "parameter" attribute is for!
Thanks.
Well, that is what the "parameter" value is used for in this
case, at
least :-).  In practice, the "parameter" attribute is a
way to pass a
single string configuration value into an Action, and means whatever
your
action interprets it to mean.  This covers the common case of
needing to
be able to pass some special parameter from struts-config.xml to an
action, without having to mess around with subclassing
ActionMapping.

> 
> At 10:26 AM 8/1/2001 -0700, you wrote:
> >This mechanism is already available in Struts. Take a look at
the
> >DispatchAction class:
> >
>
>http://jakarta.apache.org/struts/api/org/apache/struts/actions/DispatchActio
> >n.html
> >
> >--
> >Martin Cooper
> >

John
Yu  
Scioworks Technologies 
e: [EMAIL PROTECTED] w:
+(65) 873 5989
w:
http://www.scioworks.com 
 m: +(65) 9782 9610 


Re: Install 1.1 using Xerces instead of JAXP1.0?

2001-08-05 Thread Craig R. McClanahan



On Sun, 5 Aug 2001, Tim Colson wrote:

> Howdy folks -
> 
>   Is it possible to install Struts 1.1 on a Tomcat 3.2.1 server which has
> JAXP 1.0 by adding Xerces into the /WEB-INF/lib directory?
> 

That's going to be a problem.  The current Struts 1.1 code depends on
JAXP/1.1.

>   Let me preface this with the stipulation that I do _not_ own the Tomcat
> install or the classpath it starts with - so please don't suggest updating
> Tomcat and/or muck with the classpath that it starts with 
> 
>   The basic question boils down to - can Struts be configured to NOT use
> JAXP and use Xerces instead from the servlet /lib dir?
> 

I know that Struts 1.1 works fine with Xerces.  The problem (in Tomcat
3.2.x) is that putting an XML parser inside your webapp will conflict with
the one in the Tomcat installation, and cause quite a lot of grief.

> Thanks!
> Timothy
> 
> 

Craig





Re: Struts with TOMCAT 3.3

2001-08-05 Thread Craig R. McClanahan



On Sun, 5 Aug 2001, Rajan Gupta wrote:

> So then TOMCAT 4.0 it is, I hope u were serious :)


Oh, yes ... Building Tomcat 4 is my day job at Sun, and I test these
together all the time.

The only thing you need to remember is that Tomcat 4 doesn't expose an XML
parser to web apps by default.  See the release notes document for more
details about how to do this.

Craig


> --- "Craig R. McClanahan" <[EMAIL PROTECTED]> wrote:
> > 
> > 
> > On Sun, 5 Aug 2001, Rajan Gupta wrote:
> > 
> > > Has anybody successfully used Struts with Tomcat 3.3?
> > > 
> > 
> > Haven't ever done so myself.  I can vouch for Tomcat 4 though :-).
> > 
> > > I was able to run my application with Struts on Tomcat 3.2 but has to
> > > upgrade to Tomcat 3.3 because of a problem with using XALAN & Xerces.
> > I am
> > > using XPath from Xalan & that resulted in conflict with tomcat 3.2
> > > libraries. My Xalan problem got resolved but Struts Template mechanism
> > > stopped working.
> > > 
> > > Is Struts tied to a certain XML parser?
> > > 
> > 
> > Struts 1.0 requires a parser that implements the JAXP/1.0 (or
> > later) APIs.  The next version of Struts will requie JAXP/1.1 instead --
> > which also includes a portable interface for XSLT engines like Xalan.
> > 
> > > Thanks in advance,
> > > Rajan
> > > 
> > 
> > Craig McClanahan
> > 
> 
> 
> __
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/
> 




Install 1.1 using Xerces instead of JAXP1.0?

2001-08-05 Thread Tim Colson

Howdy folks -

  Is it possible to install Struts 1.1 on a Tomcat 3.2.1 server which has
JAXP 1.0 by adding Xerces into the /WEB-INF/lib directory?

  Let me preface this with the stipulation that I do _not_ own the Tomcat
install or the classpath it starts with - so please don't suggest updating
Tomcat and/or muck with the classpath that it starts with 

  The basic question boils down to - can Struts be configured to NOT use
JAXP and use Xerces instead from the servlet /lib dir?

Thanks!
Timothy




disallowing access to action class input forms

2001-08-05 Thread Jon Brisbin

I'm not sure how elegant this solution is, but I thought I'd post this for
the archives...

To disallow "normal" access to your action class' .jsp pages, I've
disallowed access to anything .jsp through normal access...I've put them in
the WEB-INF directory before, but on windows, you'll run into major problems
if your template files get below say three directories deep (the generated
filename becomes too long)...my solution was to use the .jhtml extension for
"normal" jsp pages, while using the .jsp extension just for action class
pages, and put them in the normal directory structure, which reduces the
length of the generated filename for jsp pages...this seems to work ok for
me since those pages are always loaded internally and not redirected to...

Jon Brisbin
www.jbrisbin.net
Lamar, MO




Re: Struts with TOMCAT 3.3

2001-08-05 Thread Rajan Gupta

So then TOMCAT 4.0 it is, I hope u were serious :)
--- "Craig R. McClanahan" <[EMAIL PROTECTED]> wrote:
> 
> 
> On Sun, 5 Aug 2001, Rajan Gupta wrote:
> 
> > Has anybody successfully used Struts with Tomcat 3.3?
> > 
> 
> Haven't ever done so myself.  I can vouch for Tomcat 4 though :-).
> 
> > I was able to run my application with Struts on Tomcat 3.2 but has to
> > upgrade to Tomcat 3.3 because of a problem with using XALAN & Xerces.
> I am
> > using XPath from Xalan & that resulted in conflict with tomcat 3.2
> > libraries. My Xalan problem got resolved but Struts Template mechanism
> > stopped working.
> > 
> > Is Struts tied to a certain XML parser?
> > 
> 
> Struts 1.0 requires a parser that implements the JAXP/1.0 (or
> later) APIs.  The next version of Struts will requie JAXP/1.1 instead --
> which also includes a portable interface for XSLT engines like Xalan.
> 
> > Thanks in advance,
> > Rajan
> > 
> 
> Craig McClanahan
> 


__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



Re: Struts with TOMCAT 3.3

2001-08-05 Thread Craig R. McClanahan



On Sun, 5 Aug 2001, Rajan Gupta wrote:

> Has anybody successfully used Struts with Tomcat 3.3?
> 

Haven't ever done so myself.  I can vouch for Tomcat 4 though :-).

> I was able to run my application with Struts on Tomcat 3.2 but has to
> upgrade to Tomcat 3.3 because of a problem with using XALAN & Xerces. I am
> using XPath from Xalan & that resulted in conflict with tomcat 3.2
> libraries. My Xalan problem got resolved but Struts Template mechanism
> stopped working.
> 
> Is Struts tied to a certain XML parser?
> 

Struts 1.0 requires a parser that implements the JAXP/1.0 (or
later) APIs.  The next version of Struts will requie JAXP/1.1 instead --
which also includes a portable interface for XSLT engines like Xalan.

> Thanks in advance,
> Rajan
> 

Craig McClanahan




Struts with TOMCAT 3.3

2001-08-05 Thread Rajan Gupta

Has anybody successfully used Struts with Tomcat 3.3?

I was able to run my application with Struts on Tomcat 3.2 but has to
upgrade to Tomcat 3.3 because of a problem with using XALAN & Xerces. I am
using XPath from Xalan & that resulted in conflict with tomcat 3.2
libraries. My Xalan problem got resolved but Struts Template mechanism
stopped working.

Is Struts tied to a certain XML parser?

Thanks in advance,
Rajan

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



RE: Form processing question

2001-08-05 Thread Greg Maletic

Thanks, Craig.  For some reason I had the impression that you couldn't use
"<%= %>" tags inside of the Struts taglibs.  I'll try it out.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
rg]On Behalf Of Craig R. McClanahan
Sent: Sunday, August 05, 2001 4:41 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Martin Cooper
Subject: RE: Form processing question




On Sun, 5 Aug 2001, Greg Maletic wrote:

> That was my idea, too, but it doesn't seem to work.  I'm doing the
> following:
>
> 
>   
> 
> 
>   
> 
>
>
> But the parser goes nuts with this.  XML doesn't allow improperly nested
> tags, so it complains that there's no matching  tag inside of
> the  tag.
>
> Does anyone have any other ideas?

How about a runtime expression?  It's illustrated below with a scriptlet
for brevity, but you could also precompute the destination in an Action,
or as a property of your form bean:

  <%
String destination = "editProductConfirmed.do";
if (request.getParameter("productId" == null)
destination = "addProductConfirmed.do";
  %>
  

In the Struts example app, you will find that I addressed this issue
differently -- the same Action is used for the "add", "edit", and
"delete" cases, and a hidden variable is included on the form to indicate
which transaction should be performed.  That way, you don't have to mess
around when designing the page.


>
> Thanks.
>

Craig

> -Original Message-
> From: Martin Cooper [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, August 04, 2001 11:27 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Form processing question
>
>
> One way to do this would be to use the Struts conditional tags to generate
a
> different URL on the page for edit versus add. You could base the decision
> on the presence or absence of your productId parameter.
>
> --
> Martin Cooper
>
>
> - Original Message -
> From: "Greg Maletic" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 02, 2001 5:09 PM
> Subject: Form processing question
>
>
> > I have a JSP that is used to edit data on a ActionForm bean.  There are
> two
> > ways for users to reach this JSP:  1) if they're adding a new object
into
> my
> > app; 2) if they're editing an existing object in my app.  I'm using two
> > mappings in my struts-config.xml file to represent these two types of
> > actions ("/add" and "/edit"), although they both map to this same JSP.
> > (Additionally, the "/edit" mapping has a parameter called "productId"
that
> > describes which product to edit, while the "/add" mapping doesn't have a
> > parameter.)
> >
> > It's the behavior when the JSP's form is submitted that I'm having
trouble
> > with.  If the JSP was reached through the "add" mapping, I want it to go
> to
> > an "/addExecute" mapping that will actually add the object.  And if the
> JSP
> > was reached through the "edit" mapping, I want the form to go to an
> > "/editExecute" mapping that will actually make the modifications to the
> > object.  (As above, the "/editExecute" mapping needs a "productId"
> parameter
> > specified--passed through from the original "/edit" mapping--while the
> > "/addExecute" mapping doesn't.)  Unfortunately, I can't figure out how
to
> > conditionally make the form submit to one of two different actions
> > ("/addExecute" or "/editExecute").
> >
> > Is there a way to make this work?  Is this the right technique for
solving
> > this problem?  If not, could someone please let me know how this is
> > typically done?
> >
> > Thanks!
> >
> > Greg
> >
> >
>
>
>
>





RE: Form processing question

2001-08-05 Thread Craig R. McClanahan



On Sun, 5 Aug 2001, Greg Maletic wrote:

> That was my idea, too, but it doesn't seem to work.  I'm doing the
> following:
> 
> 
>   
> 
> 
>   
> 
> 
> 
> But the parser goes nuts with this.  XML doesn't allow improperly nested
> tags, so it complains that there's no matching  tag inside of
> the  tag.
> 
> Does anyone have any other ideas?

How about a runtime expression?  It's illustrated below with a scriptlet
for brevity, but you could also precompute the destination in an Action,
or as a property of your form bean:

  <%
String destination = "editProductConfirmed.do";
if (request.getParameter("productId" == null)
destination = "addProductConfirmed.do";
  %>
  

In the Struts example app, you will find that I addressed this issue
differently -- the same Action is used for the "add", "edit", and
"delete" cases, and a hidden variable is included on the form to indicate
which transaction should be performed.  That way, you don't have to mess
around when designing the page.


> 
> Thanks.
> 

Craig

> -Original Message-
> From: Martin Cooper [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, August 04, 2001 11:27 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Form processing question
> 
> 
> One way to do this would be to use the Struts conditional tags to generate a
> different URL on the page for edit versus add. You could base the decision
> on the presence or absence of your productId parameter.
> 
> --
> Martin Cooper
> 
> 
> - Original Message -
> From: "Greg Maletic" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 02, 2001 5:09 PM
> Subject: Form processing question
> 
> 
> > I have a JSP that is used to edit data on a ActionForm bean.  There are
> two
> > ways for users to reach this JSP:  1) if they're adding a new object into
> my
> > app; 2) if they're editing an existing object in my app.  I'm using two
> > mappings in my struts-config.xml file to represent these two types of
> > actions ("/add" and "/edit"), although they both map to this same JSP.
> > (Additionally, the "/edit" mapping has a parameter called "productId" that
> > describes which product to edit, while the "/add" mapping doesn't have a
> > parameter.)
> >
> > It's the behavior when the JSP's form is submitted that I'm having trouble
> > with.  If the JSP was reached through the "add" mapping, I want it to go
> to
> > an "/addExecute" mapping that will actually add the object.  And if the
> JSP
> > was reached through the "edit" mapping, I want the form to go to an
> > "/editExecute" mapping that will actually make the modifications to the
> > object.  (As above, the "/editExecute" mapping needs a "productId"
> parameter
> > specified--passed through from the original "/edit" mapping--while the
> > "/addExecute" mapping doesn't.)  Unfortunately, I can't figure out how to
> > conditionally make the form submit to one of two different actions
> > ("/addExecute" or "/editExecute").
> >
> > Is there a way to make this work?  Is this the right technique for solving
> > this problem?  If not, could someone please let me know how this is
> > typically done?
> >
> > Thanks!
> >
> > Greg
> >
> >
> 
> 
> 
> 




Re: Exposing Application Scope Attributes in Layered Applicatoins

2001-08-05 Thread Craig R. McClanahan



On Sun, 5 Aug 2001, Ted Husted wrote:

> "Craig R. McClanahan" wrote:
> > > The Generic Connection Pool works fine with the dbTags, but they can
> > > lookup the DataSource through the pageContext.
> 
> It was added late in the development cycle, but they do support JNDI
> lookups, as well as a DataSource in the ServletContext, and so they are
> compatible with Struts, and also with gizmos like PoolMan. 
> 
> There is also a patch pending that I gave to Morgan which extends the
> ResultSet tag for RowSets. The JAR is on More About Struts if anyone is
> in a hurry ;-)
> 
> < http://husted.com/about/struts >
> 
> > Unfortunately, from the perspective of the web application, the JNDI
> > context created for you by the app server is read only, and is configured
> > solely through container-specific administration.
> 
> Being read-only is fine, but it sounds like how the ServletContext would
> be accessed by other players is undefined. Pity, since, as you noted, it
> would help with tier separation. But, Tomcat 4's support for JNDI Data
> Sources will solve the immediate problem. I had been using another
> container that supports this too, but need to have it work with Tomcat
> as well. (After all, everything should ;-)
> 

That's one of the reasons I wanted this in Tomcat ... so that others would
be forced to :-).

If you're willing to stray into being Tomcat-4--specific, you can actually
create your own object factories for other kinds of resources besides
connection pools.  (There is a standard one to create JavaMail sessions,
for example).  Thus, it *would* be possible in Tomcat to expose the Struts
resources this way, but it would not be portable.

> -Ted.
> 

Craig





RE: Form processing question

2001-08-05 Thread Greg Maletic

Actually, let me correct that last post...the %>s at the end of each
logic:present tag are NOT in my JSP.  That was a typo on my part when I was
putting it into the e-mail.

Sorry.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
rg]On Behalf Of Greg Maletic
Sent: Sunday, August 05, 2001 4:29 PM
To: Martin Cooper; [EMAIL PROTECTED]
Subject: RE: Form processing question


That was my idea, too, but it doesn't seem to work.  I'm doing the
following:









But the parser goes nuts with this.  XML doesn't allow improperly nested
tags, so it complains that there's no matching  tag inside of
the  tag.

Does anyone have any other ideas?

Thanks.

-Original Message-
From: Martin Cooper [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 04, 2001 11:27 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Form processing question


One way to do this would be to use the Struts conditional tags to generate a
different URL on the page for edit versus add. You could base the decision
on the presence or absence of your productId parameter.

--
Martin Cooper


- Original Message -
From: "Greg Maletic" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 02, 2001 5:09 PM
Subject: Form processing question


> I have a JSP that is used to edit data on a ActionForm bean.  There are
two
> ways for users to reach this JSP:  1) if they're adding a new object into
my
> app; 2) if they're editing an existing object in my app.  I'm using two
> mappings in my struts-config.xml file to represent these two types of
> actions ("/add" and "/edit"), although they both map to this same JSP.
> (Additionally, the "/edit" mapping has a parameter called "productId" that
> describes which product to edit, while the "/add" mapping doesn't have a
> parameter.)
>
> It's the behavior when the JSP's form is submitted that I'm having trouble
> with.  If the JSP was reached through the "add" mapping, I want it to go
to
> an "/addExecute" mapping that will actually add the object.  And if the
JSP
> was reached through the "edit" mapping, I want the form to go to an
> "/editExecute" mapping that will actually make the modifications to the
> object.  (As above, the "/editExecute" mapping needs a "productId"
parameter
> specified--passed through from the original "/edit" mapping--while the
> "/addExecute" mapping doesn't.)  Unfortunately, I can't figure out how to
> conditionally make the form submit to one of two different actions
> ("/addExecute" or "/editExecute").
>
> Is there a way to make this work?  Is this the right technique for solving
> this problem?  If not, could someone please let me know how this is
> typically done?
>
> Thanks!
>
> Greg
>
>







RE: Form processing question

2001-08-05 Thread Greg Maletic

That was my idea, too, but it doesn't seem to work.  I'm doing the
following:









But the parser goes nuts with this.  XML doesn't allow improperly nested
tags, so it complains that there's no matching  tag inside of
the  tag.

Does anyone have any other ideas?

Thanks.

-Original Message-
From: Martin Cooper [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 04, 2001 11:27 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Form processing question


One way to do this would be to use the Struts conditional tags to generate a
different URL on the page for edit versus add. You could base the decision
on the presence or absence of your productId parameter.

--
Martin Cooper


- Original Message -
From: "Greg Maletic" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 02, 2001 5:09 PM
Subject: Form processing question


> I have a JSP that is used to edit data on a ActionForm bean.  There are
two
> ways for users to reach this JSP:  1) if they're adding a new object into
my
> app; 2) if they're editing an existing object in my app.  I'm using two
> mappings in my struts-config.xml file to represent these two types of
> actions ("/add" and "/edit"), although they both map to this same JSP.
> (Additionally, the "/edit" mapping has a parameter called "productId" that
> describes which product to edit, while the "/add" mapping doesn't have a
> parameter.)
>
> It's the behavior when the JSP's form is submitted that I'm having trouble
> with.  If the JSP was reached through the "add" mapping, I want it to go
to
> an "/addExecute" mapping that will actually add the object.  And if the
JSP
> was reached through the "edit" mapping, I want the form to go to an
> "/editExecute" mapping that will actually make the modifications to the
> object.  (As above, the "/editExecute" mapping needs a "productId"
parameter
> specified--passed through from the original "/edit" mapping--while the
> "/addExecute" mapping doesn't.)  Unfortunately, I can't figure out how to
> conditionally make the form submit to one of two different actions
> ("/addExecute" or "/editExecute").
>
> Is there a way to make this work?  Is this the right technique for solving
> this problem?  If not, could someone please let me know how this is
> typically done?
>
> Thanks!
>
> Greg
>
>






Re: Exposing Application Scope Attributes in Layered Applicatoins

2001-08-05 Thread Ted Husted

"Craig R. McClanahan" wrote:
> > The Generic Connection Pool works fine with the dbTags, but they can
> > lookup the DataSource through the pageContext.

It was added late in the development cycle, but they do support JNDI
lookups, as well as a DataSource in the ServletContext, and so they are
compatible with Struts, and also with gizmos like PoolMan. 

There is also a patch pending that I gave to Morgan which extends the
ResultSet tag for RowSets. The JAR is on More About Struts if anyone is
in a hurry ;-)

< http://husted.com/about/struts >

> Unfortunately, from the perspective of the web application, the JNDI
> context created for you by the app server is read only, and is configured
> solely through container-specific administration.

Being read-only is fine, but it sounds like how the ServletContext would
be accessed by other players is undefined. Pity, since, as you noted, it
would help with tier separation. But, Tomcat 4's support for JNDI Data
Sources will solve the immediate problem. I had been using another
container that supports this too, but need to have it work with Tomcat
as well. (After all, everything should ;-)

-Ted.



Re: Exposing Application Scope Attributes in Layered Applicatoins

2001-08-05 Thread Craig R. McClanahan



On Sun, 5 Aug 2001, Ted Husted wrote:

> So there is not a way to access the ServletContext attributes without a
> direct link to a servlet or a JSP?
> 

Well, you could pass a reference to the ServletContext into your bean, but
that's still requiring a reference to the web tier APIs -- which it sounds
like you're trying to avoid (for good reason).

> The Generic Connection Pool works fine with the dbTags, but they can
> lookup the DataSource through the pageContext. 
> 

A really cool enhancement to dbtags would be to add the option of looking
up a data source via JNDI.  All it would take is an alternative attribute
for the  tag.

> If it were possible, it may also be interesting to be able to tap into
> the ActionMappings and MessageResources that Struts exposes through the
> Application context, from library utilities that are running in the same
> application context, without a direct link to a particular servlet. 
> 

Unfortunately, from the perspective of the web application, the JNDI
context created for you by the app server is read only, and is configured
solely through container-specific administration.

On the other hand, a few other approaches come to mind:

* (Hard) implement a JNDI context *inside* the web app.

* (Medium) store serialized versions of the Struts application
  objects in a JNDI-accessed directory server (or, for that
  matter, a JDBC-accessed database).  Of course, you've still
  got the "chicken and egg" problem of how to gain access to
  the directory server or database ...

* (Easy) Use static variables and methods to provide access
  to application resources.  (Turbine takes this approach
  for almost everything).  I chose not to do this in Struts
  because I've seen lots of people get themselves in trouble
  with global variables that are accessible for both read *and*
  write anywhere in the app.

> -Ted.
> 

Craig


> "Craig R. McClanahan" wrote:
> > You won't be able to use the Struts connection pool directly, but all J2EE
> > application servers (and some servlet containers, such as Tomcat 4) let
> > you configure a connection pool that can be accessed via JNDI.  I
> > responded to a similar question with the details of this earlier today, so
> > it should show up shortly.
> 




Re: Exposing Application Scope Attributes in Layered Applicatoins

2001-08-05 Thread Ted Husted

So there is not a way to access the ServletContext attributes without a
direct link to a servlet or a JSP?

The Generic Connection Pool works fine with the dbTags, but they can
lookup the DataSource through the pageContext. 

If it were possible, it may also be interesting to be able to tap into
the ActionMappings and MessageResources that Struts exposes through the
Application context, from library utilities that are running in the same
application context, without a direct link to a particular servlet. 

-Ted.

"Craig R. McClanahan" wrote:
> You won't be able to use the Struts connection pool directly, but all J2EE
> application servers (and some servlet containers, such as Tomcat 4) let
> you configure a connection pool that can be accessed via JNDI.  I
> responded to a similar question with the details of this earlier today, so
> it should show up shortly.



Re: Exposing Application Scope Attributes in Layered Applicatoins

2001-08-05 Thread Craig R. McClanahan



On Sat, 4 Aug 2001, Ted Husted wrote:

> Is there a way to hook into a application scope attributes without a
> direct link to a servlet? 
> 
> Perhaps through JNDI? 
> 
> Specifically, I'd like to hook into the Generic Connection Pool's
> datasource, that's exposed as "org.apache.struts.action.DATA_SOURCE" in
> the application context, without specifically linking into Struts or
> HTTP. (It's a layered architecture thing.) 
> 
> -Ted.
> 

You won't be able to use the Struts connection pool directly, but all J2EE
application servers (and some servlet containers, such as Tomcat 4) let
you configure a connection pool that can be accessed via JNDI.  I
responded to a similar question with the details of this earlier today, so
it should show up shortly.

Craig





Re: Struts Fundermentals

2001-08-05 Thread Craig R. McClanahan

Alternatively, I've also seen people understand what Struts is when you
call it a "framework".  You build your application "on top of" the
framework, and in some advanced cases you might need to customize some of
the framework's internals.  But essentially none of Struts actually "shows
through" directly to an end user of the application that is created on top
of Struts.

Craig



On Fri, 3 Aug 2001, Ted Husted wrote:

> In simplest terms, Struts is a toolkit. 
> 
> Or, as you say, a collection of Java classes.
> 
> Struts provides essential development mechanisms required by modern 
> Web applications. Without Struts, a developer needs to construct a 
> good number of support classes to create an application. (Java !=
> FileMaker). With Struts, these support classes are already written,
> tested, documented, and subjected to the peer review of thousands of
> other developers. 
> 
> To create an *application* with Struts, you need to write at least one
> Action class, and provide a configuration file with at least one
> ActionMapping. 
> 
> -Ted.
> 
> 
> Rodney Smith wrote:
> > 
> > Hallo,
> > 
> > I have a question that I should really know, but I honestly could not answer
> > without getting confirmation of other Struts users.
> > I have been asked many times about what is struts and I have responded it is
> > a open source framework useful for building  web applications in Java
> > Servlets and Java Server Pages.
> > But then they say what is Struts a application or what? I was lost for words
> > I thought it was claster of class, but unsure and I didn't think it was a
> > software. Could some one please enlighten me, so a can spread the correct
> > information on Struts and how good it is.
> > 
> > Kind Regards
> > Rodney Smith
> > 
> > --
> > Sent through GMX FreeMail - http://www.gmx.net
> 




Re: Struts Design patterns

2001-08-05 Thread Ted Husted

"Craig R. McClanahan" wrote:
> To handle lots of parameters to an Action, one very simple mechanism
> would be to interpret the single "parameter" included in an  as
> the name of a properties file resource containing your other configuration
> items.  Otherwise, you have to go to the pain of extending ActionMapping
> to have some additional properties, and then using nested
>  

3) Handle it like name of a properties file resource

-Ted.



Re: Stust start up error

2001-08-05 Thread Craig R. McClanahan



On Fri, 3 Aug 2001, Martin Fekete wrote:

> problem is that struts.jar in tomcat lib directory don't contain
> org.apache.struts.webapp.example.User.
> this class is only in struts.jar in struts-example directory.
> 

Actually, it is not there either.  The "struts.jar" file contains *only*
the standard framework classes, not the examples classes.

When you open up "struts-example.war", you will find that the
application-specific classes and resources are in the "/WEB-INF/classes"
directory.  (The sources for these classes are also included in
"/WEB-INF/src").


> feky
> 

Craig McClanahan


> - Original Message -
> From: "keith wong" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, August 03, 2001 7:27 AM
> Subject: Stust start up error
> 
> 
> > Hi All,
> > I try to add-on the Struts on Tomcat 3.2.3 and don't
> > know why having error on here.
> > JAVA_HOME=C:\jdk1.3.0_02
> > TOMCAT_HOME=D:\jakarta-tomcat-3.2.3.
> > error message attached.
> >
> > Thanks in advance.
> >
> > Keith
> >
> > ++
> > 2001-08-02 22:04:07 - ContextManager: Adding context
> > Ctx( /examples )
> > 2001-08-02 22:04:07 - ContextManager: Adding context
> > Ctx( /admin )
> > Starting tomcat. Check logs/tomcat.log for error
> > messages
> > 2001-08-02 22:04:07 - ContextManager: Adding context
> > Ctx(  )
> > 2001-08-02 22:04:07 - ContextManager: Adding context
> > Ctx( /struts-example )
> > 2001-08-02 22:04:07 - ContextManager: Adding context
> > Ctx( /test )
> > New org.apache.struts.webapp.example.User
> > Begin event threw exception
> > java.lang.ClassNotFoundException:
> > org.apache.struts.webapp.example.User
> > at
> > java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> > at
> > java.security.AccessController.doPrivileged(Native
> > Method)
> > at
> > java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> > at
> > java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> > at
> > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
> > at
> > java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> > at
> >
> org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:164
> )
> > at
> > org.apache.commons.digester.Digester.startElement(Digester.java:624)
> > at
> > org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
> > at
> >
> org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
> or.java:1214)
> > at
> >
> org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
> r.java:1862)
> > at
> >
> org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
> LDocumentScanner.java:1
> > 238)
> > at
> >
> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
> java:381)
> > at
> > org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
> > at
> > javax.xml.parsers.SAXParser.parse(SAXParser.java:374)
> > at
> > javax.xml.parsers.SAXParser.parse(SAXParser.java:192)
> > at
> > org.apache.commons.digester.Digester.parse(Digester.java:859)
> > at
> >
> org.apache.struts.webapp.example.DatabaseServlet.load(DatabaseServlet.java:2
> 52)
> > at
> >
> org.apache.struts.webapp.example.DatabaseServlet.init(DatabaseServlet.java:1
> 75)
> > at
> > javax.servlet.GenericServlet.init(GenericServlet.java:258)
> > at
> > org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
> > at
> > org.apache.tomcat.core.Handler.init(Handler.java:215)
> > at
> > org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296)
> > at
> >
> org.apache.tomcat.context.LoadOnStartupInterceptor.contextInit(LoadOnStartup
> Interceptor.java:130)
> > at
> > org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:491)
> > at
> > org.apache.tomcat.core.ContextManager.init(ContextManager.java:453)
> > at
> > org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:195)
> > at
> > org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)
> > cannot load servlet name: database: Cannot load
> > database from '/WEB-INF/database.xml'
> > register('-//Apache Software Foundation//DTD Struts
> > Configuration 1.0//EN',
> > 'jar:file:/D:/jakarta-tomcat-3.2.3
> > /lib/struts.jar!/org/apache/struts/resources/struts-config_1_0.dtd'
> > register('-//Apache Software Foundation//DTD Struts
> > Configuration 1.1//EN',
> > 'jar:file:/D:/jakarta-tomcat-3.2.3
> > /lib/struts.jar!/org/apache/struts/resources/struts-config_1_1.dtd'
> > register('-//Sun Microsystems, Inc.//DTD Web
> > Application 2.2//EN',
> > 'jar:file:/D:/jakarta-tomcat-3.2.3/lib/stru
> > ts.jar!/org/apache/struts/resources/web-app_2_2.dtd'
> > register('-//Sun Microsystems, Inc.//DTD Web
> > Application 2.3//EN',
> > 'jar:file:/D:/jakarta-tomcat-3.2.3/lib/stru
> > ts.jar!/org

RE: DataSource timeouts?

2001-08-05 Thread Craig R. McClanahan



On Thu, 2 Aug 2001 [EMAIL PROTECTED] wrote:

> I understand that--my app does "close" connections (release back to the 
> pool).  The problem is that the pool itself maintains open connections to 
> the database, and doesn't seem to recover very well when the databsae dies 
> and comes back.
> 
> -jason
> 
> 

An enhancement to GenericDataSource was added just before Struts 1.0 was
released that helps to deal with this.  You can define an SQL statement
that will be executed by the connection pool before it returns the
connection to your application.  If this statement throws any sort of
exception, the connection pool assumes that this connection is stale and
just throws it away (eventually, all the connections that existed before
the database bounce will have this happen to them).

You can specify one of two properties to set the "ping" command, using a
 element nested inside your  element:

* Set the "pingCommand" property to an SQL command to be executed that
  does not return any result set (i.e. it is not a SELECT).

* Set the "pingQuery" property to an SQL SELECT command that returns
  a result set.

The correct choice depends on what your database is, and to some degree
what tables you have set up.  Because the "ping" is executed every time
you grab a connection from the pool, you obviously want to use something
that executes very quickly.  On the other hand, you will want to test to
make sure it reliably detects bounced databases with your particular JDBC
driver.

See the JavaDocs for org.apache.struts.util.GenericDataSource for more
information.

Craig McClanahan




Re: Struts Design patterns

2001-08-05 Thread Craig R. McClanahan



On Thu, 2 Aug 2001, Ted Husted wrote:

> I very much like the idea of DispatchAction; I'm just trying to minimize
> the use of query strings. 
> 

Of course, it works with a hidden variable too.

> To do that, I've been using the ActionMapping Parameter property for
> other things. So if a mapping performs a select, I might have
> parameter="select" in the config. The Action then uses that to determine
> what to do, since my Actions tend to be multipurpose, and used by
> several different mappings.
> 
> In the case of the CRUD operations, the ancestor method looks at this
> parameter, and calls a method in a Helper object. The actual calls to
> the Data Access object happen here. All the top level instance does is
> call crud() with almost the same signature as perform() itself uses. The
> signature uses interfaces, and you could actually have one of these crud
> Actions per application, just by changing Helper objects.
> 
> I working on new version of this, with Helpers that use ArrayLists
> instead of RowSets. I need to have milestone version done tomorrow, and
> should have some classes to share next week.
> 

Should be interesting to see what you come up with.

> On the DEV side of of this, I'm wondering if we should to start to treat
> "parameter" like a real query string, and get multiple use out of it.
> DispatchAction, could just look for the first "parameter", but we could
> have others in the usual way, like parameter="method&task=select". This
> could mean replicating the getParameter* methods from
> HttpServletRequest, but have them act on the internal parameter property
> instead.
> 
> If parameter were multi-use, it might also be useful to have
> DispatchAction look for a cannonical "perform" parameter first, as in
> parameter="DISPATCH_ACTION=select" (before reverting to the original
> hehavior). That way I would have the option of giving each "perform()"
> it's own ActionMapping.
> 

The "parameter" attribute of an  element *is* multi-use, at least
to my way of thinking -).  It is interpreted solely by the Action class
you have specified, so it can mean whatever that Action wants it to mean.
DispatchAction happens to use the particular interpretation of parameter
being the name of a request parameter to be processed.  But FooAction,
BarAction, and BazAction can certainly have their own interpretations.

To handle lots of parameters to an Action, one very simple mechanism
would be to interpret the single "parameter" included in an  as
the name of a properties file resource containing your other configuration
items.  Otherwise, you have to go to the pain of extending ActionMapping
to have some additional properties, and then using nested
 -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 425-0252; Fax 716 223-2506.
> -- http://www.husted.com/about/struts/
> 

Craig


> 
> "Craig R. McClanahan" wrote:
> > 
> > On Mon, 23 Jul 2001, Ted Husted wrote:
> > 
> > > I would, yes.
> > >
> > > I use one Action class for all four CRUD operations on a table (or
> > > logical view), along with any special retrievals.
> > >
> > 
> > Are you mapping this to four different actions?  if so, you've got four
> > instances of the Action class (even though it's all the same class, so
> > your source code maintanence load is lower).
> > 
> > One way to eliminate this small amount of overhead would be to try the
> > dispatch standard action (org.apache.struts.actions.DispatchAction).  This
> > lets you (in effect) give a single Action class more than one
> > "perform" method, selected by a request parameter.  This can be very
> > helpful in situations where different Actions logically fit together, like
> > CRUD maintenance transactions.
> > 
> > Craig McClanahan
> 




Re: How to pre-populate an actionForm in the perform method?

2001-08-05 Thread Craig R. McClanahan



On Thu, 2 Aug 2001, Hartmut Bernecker wrote:

> Hello,
> 
> when a URL (myUrl.do) is invoced, the ActionServlet instantiates a
> myForm (according to the struts-config.xml), forwards control to a
> myAction object; the perform() method of myAction calls the reset()
> method of the myForm object and then forwards to a JSP page.
> 
> Would some of you give me a piece of code that shows me how myForm can
> be prepopulated with some data before been displayed by the JSP page??
> IMHO that code should be in the perfom() method.
> 

I would suggest using a separate action to prepopulate your form bean.

In a previous response (earlier today) I outlined the processing flow that
the Struts example app does, which illustrates exactly this design
pattern.

> TIA for ur help!
> Hartmut Bernecker
> 

Craig





Re: Struts and Tomcat 4.0 Beta 6

2001-08-05 Thread Craig R. McClanahan



On Wed, 1 Aug 2001, Jon Brisbin wrote:

> i haven't successfully got a struts app working in catalina...i have
> numerous classloader issues...i can't even get the example app to work
> right...i also use xsl, so that's an issue for me, but the basic app itself
> doesn't like catalina's classloading very well...not sure on the
> specifics...
> 
> if you get it working, though, please let me know so i can try it again :-)
> 

Rule #1 -- you need to make an XML parser available to your
webapp!  Either copy it into the /WEB-INF/lib directory of the
struts-example webapp, or make one globally available in
$CATLINA_HOME/lib.

See the release notes included with Tomcat 4.0-b6 for more information
about XML parsers in Tomcat.

> Jon Brisbin
> www.jbrisbin.net
> 

Craig 


> 
> - Original Message -
> From: "Nicky Eshkenazi" <>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 01, 2001 4:51 PM
> Subject: Struts and Tomcat 4.0 Beta 6
> 
> 
> > Hey guys,
> >
> > Has anybody tried the Struts with the latest Tomcat 4.0 Beta 6?
> > Are there any issues/ problems?
> >
> > thanks,
> > Nicky
> >
> 
> 




Re: How to specify a URL in the path

2001-08-05 Thread Craig R. McClanahan



On Wed, 1 Aug 2001 [EMAIL PROTECTED] wrote:

> 
> Hi
> 
> How do I specify a URL in the below
> 
>  
> 
> Instead of /abc.jsp , I need it to go to say http://www.something.com
> Can this be done ?
> 

Normally, Struts uses a RequestDispatcher.forward() to switch the user to
the requested page, and this only works within the same webapp.  However,
you can set up your  to do a redirect instead:

  http://www.something.com"/>

and Struts will do a response.sendRedirect() to this URL, instead of a
RequestDispatcher.forward().

> Thanks
> Vipin
> 
> 
Craig





Re: processPopulate() call configurable?

2001-08-05 Thread Craig R. McClanahan



On Wed, 1 Aug 2001, Kapila, Ranjit wrote:

> Hi,
> 
> In the ActionServlet.process() method, the processPopulate() method is
> always called. Is there any way to set some request attribute etc so
> that the processPopulate call is configurable.
> 

If you don't want processPopulate() to be called, just omit the form bean
from your  element.

> The underlying problem is that if I prefill my form, all the values are
> overwritten by the Request objects current parameter values.
> 
> I this something that other people have run into? Any work around?
> 

If your case is what I'm thinking it is, you probably want to consider
using different actions for prepopulating (and then displaying) a form,
versus accepting (and processing) the form submit.

Consider in the struts-example application what happens when you select
the "Edit your registration profile" option from the main menu:

* This link goes to the "/editRegistration" action, which
* Prepopulates the form bean, and
* Forwards to the "/registration.jsp" page to display it with
  values from the "database".
* Then, the form is submitted to the "/saveRegistration" action,
  which validates the input (returning on any errors) or does
  the appropriate database action.

> Thanks,
> 
> Ranjit
> 
> 

Craig





Re: AW: AW: action-mapping: why must the action-Attribute path beequivalent to the name of the jsp?

2001-08-05 Thread Craig R. McClanahan



On Thu, 2 Aug 2001, John Yu wrote:

> Martin,
> 
> Oh, I see. That's what the "parameter" attribute is for! Thanks.

Well, that is what the "parameter" value is used for in this case, at
least :-).  In practice, the "parameter" attribute is a way to pass a
single string configuration value into an Action, and means whatever your
action interprets it to mean.  This covers the common case of needing to
be able to pass some special parameter from struts-config.xml to an
action, without having to mess around with subclassing ActionMapping.


> --
> John
> 

Craig



> 
> At 10:26 AM 8/1/2001 -0700, you wrote:
> >This mechanism is already available in Struts. Take a look at the
> >DispatchAction class:
> >
> >http://jakarta.apache.org/struts/api/org/apache/struts/actions/DispatchActio
> >n.html
> >
> >--
> >Martin Cooper
> >
> >
> >- Original Message -
> >From: "John Yu" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Wednesday, August 01, 2001 1:48 AM
> >Subject: Re: AW: AW: action-mapping: why must the action-Attribute path be
> >equivalent to the name of the jsp?
> >
> >
> > > I share a similar concern.
> > >
> > > I'm wondering if it makes sense to extend Struts' mapping architecture
> > > so that it will also look into a 'magic' url parameter and dispatch
> > > accordingly.
> > >
> > > For example, if the URL is
> > >
> > >
> > >
> > > MyAction.do?subAction=Create
> > >
> > >
> > >
> > >
> > > the ActionServlet will dispatch the request to the MyActionCreate class
> > > given the following (enhanced) action mapping.
> > >
> > >   
> > >
> > > This will make it easily to have forms with multiple buttons which
> > > require different actions.
> > > --
> > > John
> > >
> > >
> > > At 10:18 AM 8/1/2001 +0200, you wrote:
> > >
> > >
> > > Isn't it against the mvc philosophy to put navigation code (e.g.
> > > control)
> > > into
> > > a tag (e.g. view) ?
> > >
> > > -Ursprungliche Nachricht-
> > > Von: Ted Husted [ mailto:[EMAIL PROTECTED]  ]
> > > Gesendet: Dienstag, 31. Juli 2001 18:42
> > > An: [EMAIL PROTECTED]
> > > Betreff: Re: AW: action-mapping: why must the action-Attribute path be
> > > equivalent to the name of the jsp?
> > >
> > >
> > > The usual solution would be to design your forms to contain hidden
> > > fields that tell the Action which operation to perform with the next
> > > request. So typically, there would be one button with a hidden field
> > > that conveyed whether this was the "FirstAction" or the "SecondAction".
> > > These would all go back to a single Action that either performed all the
> > > operations, or forwarded onto another Action.
> > >
> > > If you will be using this button that much, you might also consider
> > > writing your own custom tag so the button could program itself from the
> > > request. In general, the request is meant to convey information to the
> > > presentation layer about how it is suppose to write itself.
> > >
> > > In my own projects, I am experimenting with ways to make the current
> > > ActionMappings available to the JSP, as they are to perform() and
> > > validate(), which starts to open several doors.
> > >
> > >
> > > [EMAIL PROTECTED] wrote:
> > > >
> > > > Thanks, at least it's a working work-around. But the ugly thing is,
> > > that
> > > in
> > > > both cases the same action is called and I am forced to call the
> > > "real"
> > > > action
> > > > from the first action depending on the pushed button.
> > > >
> > > > + Action inserts "fire" bean into rquest context
> > > > + Forward to JSP
> > > > + JSP checks to see if fire==first. If so, write TheFirstAction button
> > > > + JSP checks to see if fire==second. If so, write TheSecondActon
> > > button
> > > > + submit "fires" action
> > > > + action does nothing and forwards to the "real" action depending on
> > > the
> > > > button.
> > > >
> > > > In my real world the page will be reused at least 5 or six times. So
> > > rather
> > > > than
> > > > putting the "Control" part of MVC in the struts-config.xml I start
> > > > piggypacking info
> > > > in the request and analysing this in the dummy action.
> > > >
> > > > However again thanks.
> > > > Peter
> > >
> > > --
> > > John Yu   Scioworks Technologies
> > > e: [EMAIL PROTECTED] w: +(65) 873 5989
> > > w:   http://www.scioworks.com
> > >    m: +(65) 9782 9610
> > >
> > >
> 
> -- 
> John Yu   Scioworks Technologies
> e: [EMAIL PROTECTED] w: +(65) 873 5989
> w: http://www.scioworks.com   m: +(65) 9782 9610 




Re: struts jsp in web-inf question

2001-08-05 Thread Craig R. McClanahan



On Tue, 31 Jul 2001, Davin M wrote:

> Hi everyone, does anyone have problems referring to their jsp pages 
> within the /WEB-INF dir? I tried to hide these jsp's so that users can't 
> directly access them (without performing actions). I'm running this example: 
> http://husted.com/about/struts/struts-stub.zip
> 
> I'm trying it with WebLogic 6.0 and I always get a 404 when I access 
> index.jsp. Did anyone else have a similar problem like this? It's really 
> puzzling me and I've been trying to configure it with no luck. I hope you 
> guys can help me out...
> 
> 

If you try to access "/WEB-INF/index.jsp" directly from a browser, a 404
is what you are *supposed* to get.  JSPs that are placed underneath
/WEB-INF can only be accessed via a request dispatcher (which is what
Struts does when you give it back an ActionForward).

You'll probably want to have your "index.jsp" page in the top-level
directory of your web app, so that users can navigate to it directly.

> Thanks in advance,
>   Davin
> 

Craig McClanahan




Re: HTTP Session Usage

2001-08-05 Thread Craig R. McClanahan



On Fri, 3 Aug 2001, Taylor, Michael(LIT) wrote:

> Does anyone know how to calculate the physical memory requirements for the
> HTTP session when running a Struts application?
> 

A session isn't really much more than a Hashtable.  The real issue is the
session attributes you store there.  If it's the same object that is
referenced somewhere else, there is essentially no extra space required
(in C++ terms, Java variables are like "references").  On the other hand,
if you are creating new objects you need to add up just the space for the
data portion of your objects (and thus, you have to recurse your way down
the object tre ...).

Some performance measurement tools probably provide some help in trying to
understand memory occupancy, but it's definitely not trivial.


> Michael Taylor
> Senior Software Developer
> 

Craig McClanahan




RE: Branch too large, Internal restriction. (?!)

2001-08-05 Thread Craig R. McClanahan



On Fri, 3 Aug 2001 [EMAIL PROTECTED] wrote:

> 
> My question is, if this is such a well known problem, why don't the
> JSP compiler authors just split up the code into a series of methods.  
> Better yet, prehaps the JSP spec should explictly say that a JSP
> compilier should be able to handle a page with resultant java code of
> any size.
> 

If only it were that easy ...

The biggest problem is with the scope of scripting variables that are
exposed by tags like .  Among the things that happens when
your page is compiled, this is implemented as a local variable inside the
_jspService() method.  If you've split _jspService() into multiple small
methods, and then try to reference those scripting variables in a spot
that's in a different method than where  was processed,
you're out of luck.

It will take some relatively sophisticated analysis of the input page to
know whether or not it's safe to split up the code into separate
methods.  The JSP compiler used in Tomcat and several other containers
(Jasper) isn't yet up to this task, because it does not keep any sort of
global model of the page over which it can perform such an analysis.

> Is there something I am overlooking or is there a container
> implementation that does this?
> 
> mark
> 
> Mark R Mascolino
> The Procter & Gamble Co.
> [EMAIL PROTECTED]
> 

Craig McClanahan (whose "day job" is working on Tomcat)




Re: Basic Error....solution ?

2001-08-05 Thread Craig R. McClanahan



On Tue, 31 Jul 2001, emmanuel.boudrant wrote:

> Hi,
> 
> Using Struts 1.0 on Apache Tomcat/4.0-b6, I've got
> this errors:
> 
> javax.servlet.ServletException: Cannot find
> ActionMappings or ActionFormBeans collection
> 
> And on another JSP
> 
> javax.servlet.ServletException: Cannot find message
> resources under key org.apache.struts.action.MESSAGE
> 

You'd have to check the Tomcat log files to be sure, but I would bet on
one of the following:

* You forgot to include a  element in the
  controller servlet definition in web.xml.

* Some sort of startup error is occurring that causes the init()
  method of the controller servlet to bomb out before completing
  the initialization of the two collections above, which are stored
  as servlet context attributes.

> 
> What's this ?
> 

Craig McClanahan




Re: Stuts behind a firewall.

2001-08-05 Thread Craig R. McClanahan



On Tue, 31 Jul 2001, Bill Clinton wrote:

> Craig,
> You say that "you should be able to run with no problems, without 
> trying to access the network."  But it seems to me that the internal 
> DTDs are used only after an attempt to access them via the network times 
> out.  Am I mistaken on this?  It seems that when I start my server 
> (either orion or resin) without internet access, it stalls for a pretty 
> good amount of time.
> 
> While this timeout may be fine when you are demoing some apps on 
> your laptop, it can be a real pain in the a$$ while developing.  Is 
> there anyway to configure struts to use the internal DTDs without trying 
> to find them on the network first?  Or anyway to change the timeout?
> 

Whether or not it tries the network first is probably an issue of which
XML parser you're using.  For me, I've detected no discernable delay that
could be attributed to this.

I've tried Struts with both JAXP and Xerces in offline situations, and
turned on the Digester's debugging output.  I'm pretty much convinced that
neither of these parser's will *ever* try the network if an alternate
registration is available.

In SAX API terms, the parser is supposed to call the
resolveEntity() method of your document handler (i.e. the Digester main
class, for the purposes of this discussion).  If the
resolveEntity() method returns a valid input source (based on matching the
public ID *exactly*), then it should just ignore the system id that would
send it out the network.

When you run with the debugging detail level turned up, do you see the
message "Resolving to alternate DTD" in the log output?  If so (and the
parser tries to access the network anyway), it's a parser problem.  If
not, that means Struts does not think your public ID matches exactly the
one it is looking for.

> Bill
> 

Craig


> 
> It seems that the internal copies of the DTDs are only accessed after
> 
> Craig R. McClanahan wrote:
> 
> > Struts maintains internal copies of the DTDs it uses (for
> > struts-config.xml and web.xml).  As long as you use the correct public
> > identifier on your configuration files (and your XML parser is correctly
> > implemented) you should be able to run with no problems, without trying to
> > access the network fr the DTDs.  In fact, I run Struts-based apps all the
> > time on a completely disconnected laptop (with Tomcat and JAXP/1.1) with
> > no problems.
> > 
> > Craig
> > 
> > 
> > On Mon, 16 Jul 2001, Grant Davies wrote:
> > 
> > 
> >> Hi,
> >> 
> >> I'm trying to test our first struts app with weblogic and our web.xml file
> >> goes out to sun for the DTD to validate the web.xml file
> >> 
> >> We are behind a firewall that uses a proxy on port 8080 for http requests,
> >> but our proxy requires us to login every time a new HTTP session is invoked.
> >> 
> >> Is there anyone who can help me configure our stuts for this?  I know this
> >> may be more of a JAVA question that stuts, but I've been lucky enough
> >> to use relaxed firewalls in the past.
> >> 
> >> Is it simpler just to remove the DTD url from the web.xml so it does not get
> >> validated?
> >> 
> >> Thanks
> >> Grant Davies
> >> Insolutions Inc.
> >> 
> >> 
> 
> 




Re: Style sheets with struts

2001-08-05 Thread Craig R. McClanahan



On Mon, 30 Jul 2001, Ines Pederiva wrote:

>   Hi.. I?m new in Struts and I?m trying to
> include style sheets in my pages.
>   How do you all use the css in your proyects?
>   Do you work with them as like in jsp or you
> use them in other way?
>   Bye!
> Ines.
> 

You can use them in JSPs just like you would in HTML.  Most of the Struts
tags have a "style" attribute to render styles directly, or a
"styleClass" attribute that identifies the CSS style to use.  (The
"styleClass" attribute on a Struts tag is translated to the
"class" attribute on the corresponding HTML tag.)

Craig





Re: Explanation about struts-config.xml

2001-08-05 Thread Craig R. McClanahan



On Mon, 30 Jul 2001, Chuong Huynh wrote:

> Hi all,
> 
> Is there any detailed exlanation about struts-config.xml file? Or is there
> any deployment tool for struts that automate creation of this file?
> 
> I found it difficult to understand the usage of all tags in this file.
> 

Have you looked at the DTD for this file?  It's got pretty comprehensive
comments.  In the Struts 1.0 binary distribution, use a text editor to
browse:

  lib/struts-config_1_0.dtd

> Thanks,
> - Chuong
> 

Craig McClanahan




Re: struts bean question (newbie)

2001-08-05 Thread Craig R. McClanahan

Davin,

Your approach will certainly work, and is sometimes the only possible
solution.  However, if your model bean and the form bean have exactly the
same set of properties, and they are of the same types, you can also say:

  PersonBean person = new PersonBean();
  PropertyUtils.copyProperties(person, form);

This does the same sort of "copy through introspection" trick that Struts
does for populating a form bean, but it doesn't do any type conversions.

Craig McClanahan


On Fri, 27 Jul 2001, Davin M wrote:

>Hi everyone. I have a general question about using the ActionForm beans 
> with regular javabeans. As my understanding goes, the ActionForm beans can 
> be populated automatically after the user submits that form. Now that the 
> ActionForm bean is populated, it runs the appropiate Action. So in this 
> action, I want to translate a ActionForm bean to a regular javabean. This is 
> because I read that the ActionForm bean is tied more to the view then the 
> model. Once I have this javabean, I'll use it to update/add/modify/delete a 
> Person in the db. Unfortunately the two beans' properties match one-to-one. 
> Like maybe for example both have these method prototypes:
> 
> public String getName()
> 
> public setName(String name)
> 
>   So my question (finally) is where should I convert these Form beans to my 
> state beans? I thought of either doing it one of two ways:
> 
> 1)in the Action class...
> 
> ...
> PersonBean person = new PersonBean();
> person.setUsername(form.getUsername());
> 
> //use person object to do something (save in session, update db,etc)
> 
> 2)in the PersonBean class...
> 
> public static PersonBean convert(ActionForm form) {
>   PersonBean person = new PersonBean();
>   person.setUsername(form.getUsername());
>   return person;
> }
> 
>   and do this in the Action class...
> 
> ...
> PersonBean person = PersonBean.convert(form);
> //use person object to do something (save in session, update db,etc)
> 
> =
> 
>With one property, it seems sort of trivial. But with a dozen or so, it 
> can really clutter the Action class in option 1). Well if you guys have any 
> insights on this, I'll be really appreciative. Thanks in advance!
> 
> 
> --Davin
> 
> _
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
> 
> 




RE: HotSpot Virtual Machine Error, Internal Error !!

2001-08-05 Thread Craig R. McClanahan

The error report *does* tell you that it's a hotspot error :-).  It even
tells you where to report the error to, so that it can get fixsed.

For the record, I've not seen any errors like this when running JDK 1.3.1.

Craig


On Thu, 26 Jul 2001, Marcel  Andres wrote:

> I use the same configuration as you do, but without hotspot. This runs well. So the 
>problem might be the hostspot (it also says that it is a hotspot virtual machine 
>errror). Try it without hotspot and send the error to sun. This will help them to 
>improve their produkt :-).
> 
> Marcel Andres
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 26, 2001 2:35 PM
> To: [EMAIL PROTECTED]
> Subject: HotSpot Virtual Machine Error, Internal Error !!
> 
> 
> I have the following error in the Tomcat window when running my application:
> 
> ...
> 2001-07-26 02:33:17 - PoolTcpConnector: Starting HttpConnectionHandler on
> 8080
> 2001-07-26 02:33:17 - PoolTcpConnector: Starting Ajp12ConnectionHandler on
> 8007
> #
> # HotSpot Virtual Machine Error, Internal Error
> # Please report this error at
> # http://java.sun.com/cgi-bin/bugreport.cgi
> #
> # Error ID: 47454E45524154452F4F502D41500E435050084B
> #
> 
> abnormal program termination
> 
> 
> Has anyone already seen this error and what is the cause ? Tomcat, Hotspot ?
> I'm running Tomcat 3.2.2 and JDK 1.3.0_02 with Struts 1.0.
> 
> Thanks
> Adriano Labate
> 




Re: Project startup advice

2001-08-05 Thread Craig R. McClanahan



On Thu, 26 Jul 2001, Bertil Karlsson wrote:

> 
> Even better, I found the information I was referring to on-line!
> 
> Ref: http://jakarta.apache.org/tomcat/tomcat-4.0-doc/appdev/index.html
> 

There is actually a newer version than this one ... and it reflects my
current recommendations based on the capabilities of Ant 1.3.  The new
stuff like dynamically building classpaths has *tremendously* eased my
life as a developer of Tomcat (which has lots of external dependencies),
and I now leave my CLASSPATH blank for all projects and let Ant worry
about it :-).

Check out the "new and improved" application developer's guide at:

http://jakarta.apache.org/tomcat/tomcat-4.0-doc-exp/appdev/index.html

(The only reason it's under "experimental" is that we're messing around
with the technology used to convert XML input into HTML output pages with
a consistent look and feel.)

> /Bertil
> 

Craig McClanahan


> Bertil Karlsson wrote:
> > 
> > If i remember correctly, I think that Tomcat 4 (beta) had some
> > documentation
> > about this bundled, that I found to be usefull.
> > 
> > Ref: http://jakarta.apache.org/tomcat/index.html
> > 
> > BRGDS
> > 
> > /Bertil
> > 
> > "Prior, Simon" wrote:
> > >
> > > Hi Guys,
> > >
> > > I am starting a new project and am going to use struts as the framework and
> > > ant as the build tool.  The project is going to be fairly large (having
> > > several subprojects) and as such I need to have a well structured
> > > development heirarchy for development of EJB's, JSP's etc.  I would like
> > > some advice on how best to partition the source files, project
> > > documentation, jar files, dtd's, tld's etc.  Currently I see the project
> > > being War'd up and deployed by ant automatically and wondered what the best
> > > way to write the build script was, maybe each subproject having its own
> > > build.xml and a recursive call to them?
> > >
> > > My question at a basic level is, when starting a new project, how do you
> > > structure your development directory heirarchy to aid clarity and ease of
> > > build (any automation ideas would be most appreciated).
> > >
> > > Thanks in advance,
> > >
> > > Simon.
> > > For optimum solutions that save you time, visit www.ds-s.com.
> 




Re: Digester addObjectCreate

2001-08-05 Thread Craig R. McClanahan



On Wed, 25 Jul 2001, Steven D. Wilkinson wrote:

> I have an object that takes an argument in the Constructor.  How do I do
> this during an addObjectCreate call?
> 

This issue was recently (well, yesterday :-) addressed in the version of
Digester that is included in the jakarta-commons project.

A new FactoryCreateRule (and corresponding addFactoryCreate() methods) was
added whereby you could register an object creation factory that would be
used to create the actual object to be pushed on to the stack.  And, the
factory's createObject() method is passed the attributes from the element
currently being digested -- so that it can, for example, use attribute
values to figure out what constructor to call.

Craig McClanahan





RE: Newbie installation question

2001-08-05 Thread Craig R. McClanahan



On Wed, 25 Jul 2001, George, Carl wrote:

> tomcat 4.0 doesn't work yet!! go back to 3.x
> 

Not true at all!  :-)

You need to check the Tomcat log files to verify this, but I'd bet you
have not placed an XML parser anywhere that your web apps can see it.  You
need to put an XML parser inside /WEB-INF/lib of your web apps, or you can
make one available to all webapps by placing one in $CATALINA_HOME/lib.

See the release notes included with Tomcat 4 for more information about
using XML parsers in Tomcat.

Craig McClanahan (whose day job is working on Tomcat 4)



> -Original Message-
> From: Jonathan Kaplan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 25, 2001 10:11 AM
> To: [EMAIL PROTECTED]
> Subject: Newbie installation question
> 
> 
> 
> Hi there, 
> 
> I am running Tomcat 4.0 b5.  After placing the struts war files into the
> webapps directory, restarting tomcat, and confirming the directories had
> been built out, I went to struts-example and received the following stack
> trace:
> 
> Looks to me like struts can't find some needed components... What am I
> missing? 
> 
> Thanks, 
> -Jonathan 
> 
> Exception Report: 
> javax.servlet.ServletException: Cannot find message resources under key
> org.apache.struts.action.MESSAGE 
> at
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
> l.java:442) 
> at org.apache.jsp.index_jsp._jspService(index_jsp.java:454) 
> at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) 
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 
> at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
> va:200) 
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379) 
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:453)
> 
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:254) 
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:194) 
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:255) 
> 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:225) 
> 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.StandardContext.invoke(StandardContext.java:2252) 
> 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.AccessLogValve.invoke(AccessLogValve.java:446) 
> 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:
> 875) 
> at
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:952)
> 
> at java.lang.Thread.run(Thread.java:484) 
> 
> Root Cause: 
> javax.servlet.jsp.JspException: Cannot find message resources under key
> org.apache.struts.action.MESSAGE 
> at
> org.apache.struts.util.RequestUtils.message(RequestUtils.java:568) 
> at
> org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:239) 
> at org.apache.jsp.index_jsp._jspService(index_jsp.java:94) 
> at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) 
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 
> at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
> va:200) 
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379) 
> at org.apache.jasper.servlet.JspServlet.service(

Re: DataSource and Factories

2001-08-05 Thread Craig R. McClanahan



On Wed, 25 Jul 2001, Bud Gibson wrote:

> This looks interesting, but I am not sure how I would use it.
> 
> Would the strategy be to set up an action to run when the application is 
> loaded?  Would the action then obtain a reference to the data source and 
> stow it in some repository using JNDI for use by the persistenc layer?
> 
> That is the solution we think will work.  Is this different from that?
> 
> Thanks,
> Bud
> 
> >DataSource can be obtained either Deployment descriptor as
> >"java:comp/jdbc/MyDataSource"
> >(associate a Jndi name to the Datasource
> >)
> >
> 
> 

J2EE-based application servers (and some servlet containers, like Tomcat
4.0) support exactly this approach (JNDI-based access to data sources).  
The idea is that you identify (in your web.xml file) a logical name for
the database connection pool you want:

  
My Database
jdbc/MyDataSource
javax.sql.DataSource
Container
Shareable
  

Somewhere in the administration tools for your server, the system
administrator can set up a connection between this logical name and a
"real" database -- typically, you can set up parameters similar to what
are in the Struts  element.

Now, in a servlet or a class called by your servlet, you can access the
connection pool like this:

  import java.sql.Connection;
  import javax.naming.InitialContext;
  import javax.sql.DataSource;

  ...

  InitialContext ic = new InitialContext();
  DataSource ds =
(DataSource) ic.lookup("java:comp/env/jdbc/MyDataSource");
  Connection conn = ds.getConnection();
  ... use this connection ...
  conn.close();  // Returns connection to the pool

As you can see, there's no need for any references to the servlet layer at
all -- this works because the naming context is set up correctly by the
container.

Craig McClanahan





RE: struts training

2001-08-05 Thread Matt Pease

Sign me up for the course!  Where might I read about these
points: ??
> > - preloading form
> > - reset() method gotcha
> > - special issues
> > - cleaning up context variables
> > - "Back" button sorrow
> > - indexed properties and iterators

Thank you-
Matt Pease
FullScreen.com
...Home of Downloadable Desktop Delights...