Re: off-theme question: about getServletConfig and getServeletContext

2004-03-21 Thread Craig R. McClanahan
Quoting Mu Mike <[EMAIL PROTECTED]>:

> does the servlet container has only one servletcontext instance for all the 
> servlets it manages? and the same to servletconfig instance?
> 

There is one ServletContext instance for each web application (which can
encompass many servlets and JSP pages).  There is one ServletConfig instance
for each servlet.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Webb access to mailing list

2004-03-21 Thread Craig R. McClanahan
Quoting tiredcasper <[EMAIL PROTECTED]>:

> yes,if there is a newsgroup ,things will be better.

Among other places, you can get a newsgroup mirror of STRUTS-USER (and lots of
other interesting lists) at .

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: security framework!!!

2004-03-21 Thread Craig R. McClanahan
(Jumping in late, and trying to catch up on several hundred email messages in my
STRUTS-USER folder, but better late than never ...)

Quoting David Friedman <[EMAIL PROTECTED]>:

> Adam,
> 
> With my structure, I might have to become a particular reseller, then flip
> into a customer of his/hers, then become one of their client accounts to
> look into a reported problem.  I worry about login identities for the
> following reasons:
> 
> Using a JAAS login, my principal would be fixed (set in stone) for my
> session.  Then, I couldn't be able to use the 'roles' settings inside
> Struts, Tiles, and JSPs to control content.
> 
> Without using a JAAS login, I also become unable to use 'roles' in Tiles and
> JSPs to control content.
> 
> Without having any theories on how to successfully (and without much
> alteration to the package[s]) use roles for Struts, Tiles, and JSPs, I'm at
> a loss how to change my identity/roles
> 
> If I made a filter to wrapper the Request with a HTTPServletRequestWrapper
> object then added my own push/pop/depth methods, I see how I could use roles
> in all of those places.
> 
> Knowing all of the above gory details, do you (or anyone) have any
> suggestions on how to make things cleaner while using roles in all of those
> places with the various levels of control I need to exert (albeit probably
> rarely switching roles) ?
> 

David,

If I understand what you're after correctly, the design you have proposed is
pretty troubling from a security perspective.  In particular, consider what
happens if your system is also logging who made what changes (so you can go
audit things later).  If users are allowed to impersonate each other, you have
no accountability at all.  From a security perspective, it is much better that
each user have a unique individual identity, and that all actions taken by that
individual are associated with that identity.

Going back to your problem, then, have you considered that an individual user
can have more than one role?  For example, if you have "manager" and "employee"
roles, you (as a manager) can have *both* of them assigned to your
UserPrincipal, and therefore you can do anything that either a "manager" or an
"employee" can do, while employees cannot execute manager functions.  This is
the way roles are typically used in J2EE applications, and it maps just as well
to your five-level hierarchy as it does a two-level one.

> Thanks (to all) for any constructive suggestions,
> David

Craig McCanahan



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] 2 JSF questions

2004-03-21 Thread Craig R. McClanahan
(Better late than never ...)

Quoting "Anderson, James H [IT]" <[EMAIL PROTECTED]>:

> 1) Since JSF is written in Java, why does Sun have 3 different download
> available, Windows, Solaris, Linux?
> 

There are OS-specific downloads of the JDK itself, because the native code
inside is different for each platform.  There are platform specific versions of
the J2EE SDK because the installer is unique to each platform  But there is
only one download of the JavaServer Faces reference implementation:

  http://java.sun.com/j2ee/javaserverfaces/download.html

> 2) Would any of those work for Mac OS X?
> 

Yes.

> Thanks,
> 
> jim
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: WAS: problems with - Help Please - ActionServlet fails on startup

2004-03-21 Thread Craig R. McClanahan
Quoting Lukas Latz <[EMAIL PROTECTED]>:

> Is there a problem with using Tomcat 3.23 and Struts 1.1 ?

Yes, there is.  Tomcat 3.2.x has many bugs with the way that class loading is
handled that make it totally unsuitable for Struts 1.1 applications.  You
should upgrade to a more current Tomcat release -- if you want realistic
support, then I'd recommend upgrading to the most recent Tomcat 5.0.x stable
release.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: roles filtered list of actions

2004-03-08 Thread Craig R. McClanahan
Quoting Frank Seaton Taylor <[EMAIL PROTECTED]>:

> Good day all,
> 
> I'm a three month old web developer and have been trying to figure out 
> how to do something described below. I've read a bunch of documentation 
> and searched mailing lists and the web for answers, but fear that my 
> inexperience is hampering me in that my tenuous grasp of this new 
> vocabulary might mislead me when what I'm reading contains the answer I 
> seek, but I don't comprehend it. Here's a stab at describing my goal:
> 
> In our struts-config.xml we have a number of actions which have roles 
> attributes. I would like to produce a table of links that initiate 
> those actions, but with some restrictions. It should only be actions 
> whose path has a certain form. (Specifically, I need to produce a list 
> of actions whose paths begin with a certain string.) In addition, only 
> those actions whose roles are valid with the current user should be 
> included. The fact that we use a custom 
> RequestProcessor.processRoles(...) may complicate matters, but I hope 
> that it doesn't.
> 
> My naive plan of attack is that since struts-config.xml is parsed and 
> stored somewhere that I ought to be able to access it's information, 
> loop through the actions and easily restrict that list to those whose 
> path matches a certain form. I'll less clear on weeding out the actions 
> whose roles apply, (What arguments would I need to 
> RequestProcessor.processRoles(...)?) but that might be clearer if I 
> knew the data structures that store struts-config.xml.
> 
> Is this a reasonable approach? If not, how about some other ideas? If 
> so, could someone point me to the data structures that store 
> struts-config.xml?
> 

Your supposition that Struts stores the metadata it reads from struts-config.xml
files is indeed correct.  The configuration beans are all in the
org.apache.struts.config package, and the "root" bean in the hierarchy is a
ModuleConfig.  If you have a single-module application, the ModuleConfig object
is a servlet context attribute stored under the key specified by the
Globals.MODULE_KEY manifest constant.  ModuleConfig beans for other modules (in
a multi-module application) are stored in servet context attributes that are
composed of this key plus the module prefix.

In both single-module and multi-module applications, Struts will also copy the
ModuleConfig for the *current* module to a request attribute under the same key
(Globals.MODULE_KEY), before the request processor is invoked.  Thus, you're
probably easier to deal with.

It might also be worth skimming through the Javadocs on all the manifest
constants in org.apache.struts.Globals to see what other standard places Struts
stores the configuration and application objects that it deas with.

> Thanks for your consideration,
> ---Frank

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [Suggestion] struts-user-newbie list

2004-03-08 Thread Craig R. McClanahan
Quoting Daniel Henrique Alves Lima <[EMAIL PROTECTED]>:

> It sounds good to me !
> 
> Andrew Petro wrote:
> 
> >Incidentally, have there been any thoughts on this list of differentiating
> >out a struts-user-newbie list from the main struts-user list?  
> >
> >I think it's wonderful to have a welcoming place for newbies to post
> >questions, but I think it might also be useful to be able to differentiate
> >opportunities to help out newbies / be helped as a newbie from
> >opportunities to ask more difficult questions / discuss more advanced
> >features of the framework.
> >
> >My two cents.
> >  
> >
> 

My experience with other communities that have tried this sort of thing is that
it tends not to work out very well.  The key problem is that the users just
after the newbie stage don't know which list to ask those "sort of beginner"
questions on.  So, I would vote against this suggestion.

More importantly, though, having a single list is better for a few compelling
reasons as well:

* As we've seen over and over again, even long time users
  who are intermediate to expert in some aspects of Struts
  can learn something from a newbie question from someone
  else about a different aspect.

* Even if you are a newbie today, you won't be tomorrow.
  Having all the answers to all the questions means that
  you only have to search a single message archive later.

If you find the message volume on STRUTS-USER overwhelming, here are some hints
to reduce the burden:

* Use a mail reader that you can configure to automatically
  filter messages into folders.  I've got my mail reader set
  up to do this for the 20 or so lists I subscribe to -- each
  goes in to a separate folder, and I deal with all the new
  messages for a particular folder at once.

* Use a mail reader that lets you sort messages by threads.
  That way, you can just skip the conversations you are not
  interested in.

* For some folks who just want to browse, subscribing in "digest"
  mode (one message per day, containing all the new traffic)
  works best.

* If you are not sitting behind a firewall that prevents it,
  many mailing lists are also visible through newsgroup gateways.
  One such example is gmane.org, which mirrors quite a few
  Apache and Jakarta mailing lists (among others).

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Updated Struts-Faces Integration Library

2004-03-08 Thread Craig R. McClanahan
I'm happy to announce the availability of the first nightly build of the
integration library supporting the use of JavaServer Faces and Struts that has
been updated to support the final release of JavaServer Faces 1.0.  This is not
a formal Apache release; however, it is intended to support experimentation and
trigger bug reports so that we can complete a release in the next couple of
months.  Pick up the files dated 20040308 (or later) from:

  http://cvs.apache.org/builds/jakarta-struts/nightly/struts-faces/

Key new features (see the README.txt file for full details):

* Supports the final release of JavaServer Faces 1.0 (previous
  versions supported the beta version).

* Fully worked out examples with and without Tiles.

* You can use value binding expressions ("#{...}") for all attributes
  of the Struts specific components, just like you can with all attributes
  of standard JavaServer Faces components.

* A managed bean named "struts" is available to provide access to
  Struts-internal objects, similar in spirit to the 
  tag in the existing libraries.

* The integration library supports either prefix mapping (/faces/*)
  or extension mapping (*.faces) for the JavaServer Faces servlet.

* You can use the new  tag to expose a Struts
  MessageResources object as a Map, so that messages can be looked
  up using value binding expressions, similar to the way that the
  standard  tag works with resource bundles.  This allows
  you to use your existing Struts application resources seamlessly with
  non-Struts component tags.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [RT Expr] for html:text property

2004-03-06 Thread Craig R. McClanahan
Quoting Craig Tataryn <[EMAIL PROTECTED]>:

> Hi, this might be a "Tomcat vs. ServletExec" thing, but I was trying the
> following under Tomcat and
> got an error message to the effect of "Null property value for 'address()'":
> 
>   
>   
>   <%=region%>
>property="address(<%=region%>).street"/>
>property="address(<%=region%>).city"/>
>   
>   
> 
> If I rewrite my html:text property as below, all is good in the world:
> 
> 
> 
> 
> Just wanted to know why the first way wouldn't work?
> 

According to the JSP 1.1 and 1.2 Specifications, it is illegal to have *part* of
an attribute value be a runtime expression.  If ServletExec accepts your first
variant, it is broken.

> Craig.

Craig (McClanahan :-)


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Extending Request Processor to append request parameter

2004-03-06 Thread Craig R. McClanahan
Quoting Geeta Ramani <[EMAIL PROTECTED]>:

> Brad:
> 
> I looked at the API and noticed the RequestProcessor is a 1.1 feature.. Your
> solution seems nice and clear!  I only have one question for you though: How
> do you "connect" the subclass of RequestProcessor that you wrote with the
> struts ActionServlet..?  Do you have to subclass the ACtionServlet too and
> then join the dots there? How do you do that?   There is a " processor"
> method
> in ActionServlet which returns the processor..but I don't see a setProcessor
> method..?

This is done in your struts-config.xml file:

  

so that each module (in a multi-module app) can have its own custom
RequestProcessor if need be.

See the documentation in the DTD file itself (lib/struts-config_1_1.dtd) for
documentation on all the things you can configure here.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Extending Request Processor to append request parameter

2004-03-06 Thread Craig R. McClanahan
Quoting Brad Balmer <[EMAIL PROTECTED]>:

> Well, I searched through the archives with no luck on 
> 'ParameterActionForward' or similar.  I ended up trying to ovveride the 
> ActionForward class but couldn't get it to work well.  Then I noticed in 
> the RequestProcessor there is a doForward() that can be ovveridden.  I 
> wrote the following and it seems to work.
> 
> Is there a better way/place to do this than the RequestProcessor?  This 
> seems like a prettly locical/central place to do this.

That is indeed a pretty logical place for this kind of thing.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] JSF RI Final is out!

2004-03-05 Thread Craig R. McClanahan
Quoting Hubert Rabago <[EMAIL PROTECTED]>:

> Btw, Craig, thank you very much for removing those underscores.
> 

Let's just say that you weren't the only person that didn't like them :-).

> Hubert

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JSF RI Final is out!

2004-03-05 Thread Craig R. McClanahan
Quoting Janarthan Sathiamurthy <[EMAIL PROTECTED]>:

> Hi,
>  
> How do i get started wiith JSF ?. 
> Any books ?
> Please advice
>  

JavaServer Faces Home Page:
  http://java.sun.com/j2ee/javaserverfaces/

Download Page:
  http://java.sun.com/j2ee/javaserverfaces/download.html

Support Forum (free registration required):
  http://forums.java.sun.com/forum.jsp?forum=427

The download includes some example applications that illustrate its use.  An
update to the JavaServer Faces Tutorial is in progress, and will be posted
shortly.

No books have been published about JavaServer Faces yet (to my knowledge),
although I know of at least five that are nearing completion, and should be
published very soon.

Nightly builds of an integation library for using JavaServer Faces and Struts
together are available, but it's still based on the beta version.  I'm
debugging the updates as I type, and will post messages here when the nightly
builds have been updated to work with the final version.


> Regards,
> Janarthan S
> 

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: struts-faces-integration-lib

2004-03-04 Thread Craig R. McClanahan
Quoting Matthias Wessendorf <[EMAIL PROTECTED]>:

> Hi,
> 
> i noticed, that JSF became final.
> Now i asked myself, when the struts-faces-lib will be shipped? that one,
> that works with 1.0_final... ;-)
> 

Well, it has to work first :-).  I'm finishing up the debugging before I commit
a version that works with the 1.0 final release (without Tiles ... the next
step will be catching up the Tiles integration as well).

My personal goal is to have a production quality version of this code released
before JavaOne.  In order for that to happen, it will need lots of testing
across a variety of existing applications, so we'll probably need some 'early
access' type snapshots in the interim.

> Is main focus now working on struts_1.2?
> or is the integration-lib "independent" of struts-1.2
> because it is in contrib-folder!
> 

So far, I've been doing the integration work against a stock Struts 1.1 install,
so it will be backwards compatible.  I'll test, of course, with Struts 1.2 as
well before we actually release anything.


> Thanks for answer! :-)
> 
> Cheers!
> --
> Matthias Weßendorf
> Aechterhoek 18
> D-48282 Emsdetten
> Email: mailto:[EMAIL PROTECTED]
> URL: http://www.wessendorf.net
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JSF RI Final is out!

2004-03-04 Thread Craig R. McClanahan
Quoting "Hookom, Jacob" <[EMAIL PROTECTED]>:

> It just uses an interface called "VariableRegistry".  So it's not JSP
> dependent (doesn't need any J2EE API's).  It's not exactly EL, it's EL, but
> instead of JSP 2.0 function invocation, you can call any method on an object
> through ":" like "There are #{order.lineItems:size} in your order".
> 

Off topic for the thread about Banten, but the JavaServer Faces expression
language functionality can be used from a servlet (or an event handler), as
well as in JSP pages.  See the javax.faces.el.ValueBinding and
javax.faces.el.MethodBinding classes, and the corresponding factory methods in
javax.faces.application.Application.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] RE: web.xml DTD for Servlet 2.3 & Struts 1.1

2004-03-04 Thread Craig R. McClanahan
Quoting Wendy Smoak <[EMAIL PROTECTED]>:

> A long time ago, Craig McClanahan wrote:
> > It is a common misconception that the public identifiers of a DTD like
> > this *must* actually be working URLs [...].
> > They are just unique strings of characters that
> > (often) happen to look like URLs.  
> > Blame the XML community for that :-).
> 
> 
> And then Yuan Saul asked:
> > If a local copy of DTD is not available, then an Internet connection
> is
> > required, in this case, does the URI has to be pointing to a working
> URL
> > where the DTD file can be retrieved?
> 
> Which is also my question, but there is no reply in the archives.
> Anyone?
> 
> Today we got a note from campus IT saying that they believed some
> problems in their J2EE apps were related to "code that connects to
> http://java.sun.com behind-the-scenes to download various DTD files
> related to parsing XML documents."
> 
> In addition to whether it happens at all (going out to the internet to
> retrieve the DTD) I'm also curious if it's the XML parser, or the
> Servlet container, etc.  What component would make the call out to get
> the DTD?
> 
> I've always wondered...
> 

Since Wendy spends quite a bit of time answering questions for users, it's only
fair that I answer this one for her :-).

The answer actually depends on your XML parser, and you can actually get
involved in the process if you want to, but for simple use cases the answer is
"yes".  If you're interested, here's a few details about how Struts (and
Tomcat, for that matter) use the commons-digester module to parse configuration
files:

* Your XML document includes a DOCTYPE header defining the DTD.  For a
  Struts config file, it would look like:

  http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";>

* This header includes two identifiers for the DTD ... the *public* identifer
  "-//Apache ..." and the *system* identifier (in this case, a URL).

* Commons Digester uses the SAX parsing APIs provided by the parser.
  Included in these APIs is an interface, which Digester implements.

* The parser calls the resolveEntity() method of the EntityResolver
  (i.e. the Digester instance), asking it to return an InputSource
  so the parser can read the DTD's contents.

* The default EntityResolver defined by SAX simply uses the system id
  as a URL and attempts to retrieve it.  With the system identifier
  given above, it will go to the jakarta.apache.org site across the
  Internet.

* Digester, however, is "smarter than the average bear" (if you remember
  Yogi Bear from growing up days :-).  It allows you to register a
  mapping from a public identifier ("-//Apache ...") to an *internal*
  resource inside the JAR file.  If you call resolveEntity() and pass
  one of the registered public ids, it will ignore the system id and
  return a stream to the internal resource.  If the public id is not
  recognized, it wil do the usual thing (using the system id instead).

* Struts pre-registers the public ids for the various versions of the
  DTD, pointing at internal resources (see the initConfigDigester() method
  of ActionServlet), so that it will never need to use the system id.

In this way, you can run Struts based applications (and Tomcat, which does the
same thing for the DTDs for web.xml files) completely disconnected from the
Internet, without changing the system ids in your XML documents.

If you find that your application is attempting to go to the Internet for DTDs
anyway, the most likely explanation is that you have a typo in the public
dentifier in your config fie.

> -- 
> Wendy Smoak
> Application Systems Analyst, Sr.
> ASU IA Information Resources Management 
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JSF RI Final is out!

2004-03-04 Thread Craig R. McClanahan
Quoting Jitender Kumar C <[EMAIL PROTECTED]>:

> Just a small doubt...
> Is this a new release?
> sorry if I put a wrong query...
> 

The main JavaServer Faces page on the web site is still not updated (talking to
our web admins about it now), but the download page does indeed point at the
1.0 *final* version of JavaServer Faces.

Craig

> -Original Message-
> From: Christian Bollmeyer [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 04, 2004 3:15 PM
> To: Struts Users Mailing List
> Subject: JSF RI Final is out!
> 
> 
> http://java.sun.com/j2ee/javaserverfaces/download.html
> 
> -- Chris
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ConcurrentModificationException

2004-03-04 Thread Craig R. McClanahan
Quoting "Sergei P. Volin" <[EMAIL PROTECTED]>:

> 
> Greetings,
> 
> That is the question! Today morning I've found the reason of my troubles. It
> was my negligence in how I assigned a value to the iterated list that I
> placed in the object which I then stored in a session for JSP's iterator. I
> declared the list in my action as a global variable, assigned a value to it
> in the protected void method which is called by the action execute method
> like this:
> 
> public class MyAction  extends Action {
> protected ArrayList list = new ArrayList();
> ...
> public ActionForward execute(...) ... {
> list = new ArrayList();
> myMethod(...);
> obj.setList(list)
> session.setAttribute("buinessObj", obj);
> ...
> return mapping.findForward(forward);
> }
> protected void myMethod(...) {
> ...
> while (rs.next()) {
> ...
> list.add(el);
> ...
> }
> }
> }
> 
> Now this piece of code looks like:
> 
> public class MyAction  extends Action {
> protected ArrayList list = new ArrayList();
> ...
> public ActionForward execute(...) ... {
> list = new ArrayList();
> myMethod(...);
> obj.setList(list)
> session.setAttribute("buinessObj", obj);
> ...
> return mapping.findForward(forward);
> }
> protected void myMethod(...) {
> ArrayList list = new ArrayList();// new
> ...
> while (rs.next()) {
> ...
> list.add(el);
> ...
> }
> this.list =list;// new
> }
> }
> 
> It looks that with this code I rid off all my troubles now - no
> ConcurrentModificationException, no doubling of list size. I made a dozen of
> tests - no exceptions and the results were correct.
> 
> Mr. Craig R. McClanahan! Am I right now with my code? Please, reply.
> Thanks a lot,

No, you are still going to have a problem with the shared instance variable when
two requests occur at the same time.  A general principle you should follow is
to *never* use instance variables in an Action (or a servlet, for that matter)
to store anything that relates only to the current request.  It's fine to use
instance variables to share things that are common to all requests, though.

An easy way to do this in your scenario would be something like this:

 public class MyAction  extends Action {
 // protected ArrayList list = new ArrayList(); (COMMENTED OUT)
 ...
 public ActionForward execute(...) ... {
 List list = myMethod(); // NEWER
 // myMethod(...); (COMMENTED OUT)
 obj.setList(list)
 session.setAttribute("buinessObj", obj);
 ...
 return mapping.findForward(forward);
 }
 // protected void myMethod(...) { (COMMENTED OUT)
 protected List myMethod(...) {  // NEWER
 ArrayList list = new ArrayList();// new
 ...
 while (rs.next()) {
 ...
 list.add(el);
 ...
 }
 // this.list =list;// new (COMMENTED OUT)
 return list;
 }
 }


Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Getting the real request url

2004-03-04 Thread Craig R. McClanahan
Quoting yoge <[EMAIL PROTECTED]>:

> Dear Hen,
> 
> Write a servletFilter and include the below code snippet in your 
> doFilter method
> 
> *String uri=(String)((HttpServletRequest)request).getAttribute("uri");
> if(uri==null)
> {
> System.out.println("Inside uri==null ");
> String 
> requestURL=((HttpServletRequest)request).getRequestURI();
> 
> ((HttpServletRequest)request).setAttribute("uri",requestURL);
>  
> }*
> 
> Then u can get the requestURL in the jsp using request.getAttribute("uri");
> 

This technique works fine.  In a Servlet 2.4 environment (Tomcat 5 or later)
environment, however, it is unnecessary ... when the Struts controller servlet
executes the RequestDispatcher.forward() call, the servlet container will
create request attributes under the following keys, to capture the path
elements of the original request (rather than the new request):

* javax.servlet.forward.request_uri
* javax.servlet.forward.context_path
* javax.servlet.forward.servlet_path
* javax.servlet.forward.path_info
* javax.servlet.forward.query_string

For more info, see Section SRV.8.4.2 of the Servlet 2.4 spec.

> --Thanks
> Yogendrababu
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ConcurrentModificationException

2004-03-03 Thread Craig R. McClanahan
Quoting "Sergei P. Volin" <[EMAIL PROTECTED]>:

> 
> I know this and I do not add/remove elements to/from list at all. Just as I
> said - only reading elements from list.
> Are jsps (Tomcat) thread safe? I'm really worry about that.
> 

Using instance variables to store request-specific state information, in a JSP
or servlet (or in a Struts Action class), is *not* thread safe, because there
is only one instance of the corresponding class, shared by simultaneous
requests.  Using local variables, though, should be fine.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Maven (was Re: [ANNOUNCE] Struts 1.2.0 Test Build available)

2004-02-27 Thread Craig R. McClanahan
Quoting Joe Germuska <[EMAIL PROTECTED]>:

> Oh yeah, also I can't go back from having versioned JAR in my lib 
> directories.  I suspect that's a matter of taste too, but I'll take 
> the overhead of pruning old JARs when new versions are deployed over 
> the mystery of knowing which versions your apps depend on any day...
> 

Interestingly, this touches on my single biggest frustration with Maven.

Professionally, I live in a world where there are some fairly large projects,
which integrate *lots* of open source projects (a very large number of
jakarta.apache.org and xml.apache.org subprojects are included).  Many of these
open source projects have overlapping dependencies on several Jakarta Commons
packages -- not a surprise, those packages were *designed* for reuse.  But
Maven (like many other build environments) encourages you to define the
specific version dependencies for each package you build independently.  That's
not good enough for enterprise development.

All of the Ant build.xml files I care about include a line like this:

  

that lets me define the individual versions of *all* dependencies for *all*
projects so that I can say, for example, use *this* version of
commons-beanutils and *that* version of commons-digester to build ***all*** of
the components that are going in to my overall exectable.  I am *so* not
interested in dealing with runtime exceptions because different dependent
packages were compiled against different versions of the dependent libraries.

Can someone please help me understand how to do this with Maven?  Without it,
I'm not planning to switch any of my personal or internal-to-Sun projects (even
if the Struts committers decide to switch Struts development itself).

> Joe

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] RE: Memory usage

2004-02-27 Thread Craig R. McClanahan
Quoting "Dhaliwal, Pritpal (HQP)" <[EMAIL PROTECTED]>:

> +1
> 
> I agree with everyone who has responded. We should not clutter this very
> friendly mailing list with things that don't belong here, that includes "not
> so nice" responses. I haven't been on many, but this is by far my favorite
> list, even though I am mainly a spectator. 
> 
> I lashed out because this question clearly didn't belong here. If the person
> had followed anything in http://www.catb.org/~esr/faqs/smart-questions.html,
> it must that they were polite. They certainly didn't do much investigation
> outside on the internet. The little bit of unfriendliness, I dunno why it
> came out. Unprofessional, it shouldn't have came out.
> 

Even questions that don't belong here deserve to be treated with respect.  That
is the single most obvious characteristic of STRUTS-USER that is distinctive
(even though it has lots of other good qualities).

Unfortunately, you decided to unload on a poster in a manner that is decidedly
out of the norm for STRUTS-USER.  Your response is the kind of behavior that
creates problems for the perception of open source projects as being "friendly"
to users or not.  If you think the topic is totally out of scope for
STRUTS-USER, then you should either (a) answer the question anyway but point
people to where they should really be asking; (b) *gently* encourage the user
to explore the other resources that are available (the archives are full of
examples of folks who have done this), or (c) shut your yap and press DELETE
instead of SUBMIT on your replies :-).

The culture of the STRUTS-USER list has always been *deliberately* different
from the "you idiot, how could you be so stupid as to ask that question in that
way" sort of attitude that far too many open source projects have. 
Fortunately, despite the fact that this is the most-subscribed-to user list at
Jakarta (ten short of 3000 at the moment), the occurrences of rude behavior are
so rare that they immediately attract notice for being out of character for
what we're trying to achieve :-).  I'd say that we've been doing a pretty good
job maintaining a friendly, welcoming, and helpful community.  I'd also like to
keep it that way.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: need help converting from session to request scope

2004-02-26 Thread Craig R. McClanahan
Quoting Mark Lowe <[EMAIL PROTECTED]>:

> sure i agree .. but I've been wanting to dick around with alternatives 
> to storing in the session for a while (since the request vs session 
> debate). and just wondered if anyone had tried read/writing to a flat 
> file as an alternative.
> 

Just remember that it's needless extra work and overhead unless the memory
occupancy actually matters.  The number of "actually matters" applications is
likely to be a fairly small percentage of the total.

> Additionally I think that sessions are stored in this way anyway so 
> might be a waste of time.

That depends on your container, and how you have it configured.  Tomcat, for
example, by default only puts sessions in memory unless you're shutting down
the app (or the server), in which case it serializes all the session objects to
disk.  However, you can configure the "PersistentManager" if you wish, which
includes the ability to swap active but idle sessions out to disk (either flat
files or to a database) in a manner similar to what operating systems do with
active but idle processes.  From the developer perspective, the nice thing
about this is it's zero extra code -- other than the need to make your session
objects Serializable, which is not typically very difficult.

> But then I imagine that session objects are 
> loaded into memory where using an old school read-write to a flat file 
> might be less greedy.
> 

Doing any I-O at all has overhead costs ... if memory is not an issue any such
approach is *guaranteed* to make your application slower than leaving the
objects in memory.

> guess its dog food time.
> 

Buying RAM is cheaper than paying for developer and testing time :-).  So is
configuring servers if they support the feature already.

Craig McClanahan


> On 26 Feb 2004, at 15:42, Paul McCulloch wrote:
> 
> > My intuitive response would be that I'd use ram freely and let the O/S 
> > worry
> > about paging stuff to disk if it runs out of physical memory. I'd 
> > *guess*
> > that the O/S can use disk for paging significantly faster than a Java
> > programmer can via the JVM & the O/S.
> >
> > I think that you'd have to run some pretty exhaustive tests in an
> > environment close to your production one to determine which method is 
> > more
> > efficient.
> >
> > Personally I'd just spend the money on a bit more ram instead of 
> > developer
> > time...
> >
> > Paul
> >
> >> -Original Message-
> >> From: Mark Lowe [mailto:[EMAIL PROTECTED]
> >> Sent: 26 February 2004 13:24
> >> To: Struts Users Mailing List
> >> Subject: Re: need help converting from session to request scope
> >>
> >>
> >> Niall
> >>
> >> Any opinions on read and writing to flat files to avoid
> >> additional ram
> >> use? Or you reckon that the reading and writing would consume similar
> >> amounts of ram? I'll get around to trying it when i get a moment.
> >>
> >> On 26 Feb 2004, at 14:04, Niall Pemberton wrote:
> >>
> >>> Given your scenario, it sounds like a good candidate for a session
> >>> scoped
> >>> form.
> >>>
> >>> I agree with what Mark Lowe said - usually/often "...theres no more
> >>> work
> >>> invloved scoping to request" - thats been the case for my
> >> app. I would
> >>> also
> >>> do what you said in a previous post - which is "clean up"
> >> the session
> >>> stuff
> >>> when they navigate away to another part of the app.
> >>>
> >>> I'm in the "do it in request unless you have good reason(s)
> >> to use the
> >>> session" camp - rather than the "anti-session" camp as it may have
> >>> appeared
> >>> in previous threads.
> >>>
> >>> Niall
> >>>
> >>> - Original Message -
> >>> From: "Paul McCulloch" <[EMAIL PROTECTED]>
> >>> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> >>> Sent: Wednesday, February 25, 2004 4:13 PM
> >>> Subject: RE: need help converting from session to request scope
> >>>
> >>>
>  My application has an Asset search form. The user can enter many
>  criteria
> >>> to
>  search on.
> 
>  Most of these criteria themselves are looked up from the database
>  (e.g the
>  Person associated with the Asset search). When the user selects a
>  search
>  criteria (e.g. the Person) I store the DTO for that person on my
>  search
>  form. The view element displays details about that Person on the
>  search
> >>> form
>  until the search form is cleared.
> 
>  Many requests will be made to find the criteria before the Asset
>  search
>  itself is performed.
> 
>  To do this using a request scope form would require that I
> >> transfer
>  all of
>  the details I want to display about that person in hidden
> >> inputs on
>  the
>  form. If the details I want to display about a Person
> >> change then I'd
>  also
>  need to change the hidden fields. In addition once I ship the
>  application
> >>> to
>  my customers they may have their own JSP developer show extra
>  prpoerties
> >

Re: multi application config

2004-02-25 Thread Craig R. McClanahan
Quoting David Evans <[EMAIL PROTECTED]>:

> Hello,
> 
> I am getting ready to create our companies intranet, which will contain
> many different applications: a time tracker, a task manager, a
> directory, etc. I will be using struts for the applications. There will
> be a filter for authentication and a default application which will
> display a menu that sends the authenticated user to the selected
> application. I am trying to decide whether to build the applications in
> a single context running struts as a multi module application or to
> configure tomcat with multiple contexts and have struts run one app per
> context. Does anyone have any advice or can anyone point to
> documentation regarding the pros and cons of each approach?
> 

There are several considerations and no one always-right answer, but here's a
couple of things that tend to push you one way or the other very quickly.

* Do you want users to be able to sign on once
  and then access all the apps they have access
  to, or is it acceptable to require login for
  each app individually?  If you're using container
  managed security, most containers (including
  Tomcat) have some sort of "single sign on"
  feature for this purpose.  With roll-your-own
  security, it might or might not be that easy.

* Do you need HttpSession state to be shared across
  all of your applications?  If so, you should
  probably put everything in one webapp.  With
  multiple webapps, your users will have a session
  in each of them, all totally independent.

* When upgrading your apps, is it acceptable to
  take them all down at once, or do you only want
  to impact the individual apps that are being
  updated?  For most company intranets, there is
  likely to be slack time where this won't matter,
  but it could be an issue for 24x7 shops.

* Is the overall size of the apps so big, and worked
  on by so many people, that it gets difficult to manage
  a single webapp configuration (and struts configuration)?
  Individual smaller Struts based apps are likely to be
  easier to deal with, but you can accomplish a lot of
  the same ease of use with Struts modules.

In fact, with a little forethought, you could probably write all your apps as
independent modules, and then try it either way, with relatively little pain.

Craig


> 
> thanks
> 
> dave
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: data transfer from Action class to jsp page

2004-02-25 Thread Craig R. McClanahan
Quoting "Pradeep, PK" <[EMAIL PROTECTED]>:

> Sending the same question again..
> 
> 
> I have this basic question.
> 
> Suppose action class calls some business object and fetches some data
> (say employee detail). How to transfer this data to jsp page which is
> reached through ActionForward?
> 
> One way I know is storing the data in session object..is there any
> better/different way
> 

If you only need the information to prepare the next response, that is exactly
what request scope attributes are for.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: More then one servlet mapping

2004-02-25 Thread Craig R. McClanahan
Quoting "Kale, Nilesh" <[EMAIL PROTECTED]>:

> Thanks for the reply Mark.
> The next question is does Struts support more than one mapping:

http://jakarta.apache.org/struts/userGuide/configuration.html#dd_config_mapping

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] - Request against Session

2004-02-14 Thread Craig R. McClanahan
Quoting Michael McGrady <[EMAIL PROTECTED]>:

> 
> >Now let us assume that the ActionForm for the record editing form needs to
> >go in session scope (nb: in request scope there is not a problem so if the
> >design can be done practically with request scope that is much better).
> 
> 
> Hi, Andrew,
> 
> Now this is becoming interesting.  Let's talk about this decision.  If we 
> are taking data from a view, wouldn't it be paramount to make sure that the 
> what we got was from that view alone?  What possible benefit would there be 
> to putting the ActionForm into session scope?
> 

The only reason a form bean should ever be in session scope is if you want it to
preserve values across requests that are not included in the form on the
current page.  An example use case would be a wizard dialog that is composed of
multiple pages, all updating the same form bean but containing different
subsets of the fields.

My recommendation is to *always* use request scope form beans if you can.  Most
of the reasons you might like to use session scope can be dealt with in other
ways -- for example, the wizard dialog scenario can be addressed by simply
including hidden input fields for all the fields that are not displayed on the
current page of the wizard.

> Michael 

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: global data objects -- best practices?

2004-02-05 Thread Craig R. McClanahan
Ooofff ... off-by-one error warning ... :-)

Quoting "Craig R. McClanahan" <[EMAIL PROTECTED]>:

> 
> If you are in a Servlet 2.4 environment, use a ServletContextListener -- this
> is
> exactly what they are defined to do.  Your contextInitialized() method is
> called once, before any requests are accepted by the app, and
> contextDestroyed() is called exactly once when the app is removed (or the
> server is shut down).

This actually works from Servlet 2.3 onward.

> If you are in a Servlet 2.3 environment, use a Struts PlugIn.  Under most
> scenarios, this will have the same effect (as long as you set the
> load-on-startup attribute in web.xml); however servlet containers are
> allowed
> to unload and reload a servlet during the lifetime of an application, which
> would cause the initialization to be redone at reload.  Fortunately,
> containers
> don't tend to do that -- especially not to a servlet that will get invoked
> as
> often as the Struts controller servlet does.
> 

This advice actually applies to Servlet 2.2 platforms, before
ServletContextListener was part of the standard Servlet spec.

> Craig McClanahan

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: global data objects -- best practices?

2004-02-04 Thread Craig R. McClanahan
Quoting [EMAIL PROTECTED]:

> hi,
> 
> I have a question regarding data objects that should be accessible from 
> the entire application and which must be created at container startup time.
> 
> I need to either create and load an existing index or load a serialized 
> index if one exists. This can be a time-consuming process, and I would 
> like to do it once when the servlet container starts, then keep the 
> index in memory thereafter and available to the entire web application.
> 
> I've seen a few different ways of doing this by searching the archives, 
> but there wasn't a definitive best practice solution that I came across, 
> and the struts API has also changed since many of the suggestions were 
> offered.
> 
> At present, I am extending the ActionServlet and taking care of the 
> initialization stuff in the subclass's init(). I place the generated 
> index in the ServletContext. This ensures that the index creation will 
> occur only once, at container startup, and that it will be available to 
> the action classes of that web application, but I'm not sure if this is 
> the best solution. Also, I have just come across plugins for the first 
> time, and it seems that they also provide a way of doing 
> application-specific initialization. Having the index creation code in 
> the ActionServlet, as it is at present, seems messy to me, so perhaps 
> that is not the best place for it.
> 
> In short, what is the best method for ensuring that a global index is 
> created exactly once, and at container startup time? At present, I am 
> subclassing ActionServlet, and doing it there, but is the plugin 
> mechanism an alternate (better?) solution? Is the ServletContext the 
> appropriate place for global data?
> 
> thanks in advance,
> 
> n.
> 

If you are in a Servlet 2.4 environment, use a ServletContextListener -- this is
exactly what they are defined to do.  Your contextInitialized() method is
called once, before any requests are accepted by the app, and
contextDestroyed() is called exactly once when the app is removed (or the
server is shut down).

If you are in a Servlet 2.3 environment, use a Struts PlugIn.  Under most
scenarios, this will have the same effect (as long as you set the
load-on-startup attribute in web.xml); however servlet containers are allowed
to unload and reload a servlet during the lifetime of an application, which
would cause the initialization to be redone at reload.  Fortunately, containers
don't tend to do that -- especially not to a servlet that will get invoked as
often as the Struts controller servlet does.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: action global forward extension

2004-02-03 Thread Craig R. McClanahan
Quoting Bradley Beddoes <[EMAIL PROTECTED]>:

> Hi All.
>  
> I wish to have some global forwards invoked as .do others as .do2 (so as
> to differentiate what filters get hit with the differing requests), Is
> this possible within struts? (Please see struts.conf below)
>  

Struts supports only one mapping to the controller servlet.

http://jakarta.apache.org/struts/userGuide/configuration.html#dd_config_mapping

Since you are using extension mapping, one thing to consider is to create an
artificial "directory" level in your action paths ("/foo/setup.do" and
"/bar/teardown.do" instead of "setup.do" and "teardown.do2").  That way, you
can have different filters on "/foo/*" and "/bar/*".

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: What does "do" stand for in .do files

2004-01-31 Thread Craig R. McClanahan
Quoting "Gopalakrishnan, Jayesh" <[EMAIL PROTECTED]>:

> The "do" is insignificant, its just what all the sample applications use and
> has somehow stayed on.

In the technical sense ("could I use "foo" instead of "do") you are absolutely
right ... there is no intrinsic meaning to "do".  However, for native speakers
of English, "do" has a natural connotation of 'go DO something" that I wanted
to pick up on, so that was my choice for the "example" mappings for the Struts
controller servlet.

Craig McClanahan

PS:  Being constructively lazy, it's also very easy to type :-).


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: struts-user being spammed

2004-01-29 Thread Craig R. McClanahan
Quoting Martin Cooper <[EMAIL PROTECTED]>:

> The struts-user list is being spammed with dozens of bogus messages. The
> titles vary slightly, including the subjects of prior messages to the
> list. Here's what we're seeing:
> 
> http://marc.theaimsgroup.com/?l=struts-user&w=2&r=1&s=%3CAUTO%3E&q=t
> 
> Can someone put a stop to this, please?
> 
> TIA.
> 
> --
> Martin Cooper
> 


I've unsubscribed this auto-responder.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: constant url

2004-01-27 Thread Craig R. McClanahan
Quoting shankarr <[EMAIL PROTECTED]>:

> Hi!
> 
> Thanks for the response.
> http://localhost:8081/log4jdemo/loginScreen.do is what I see in my url.
> I would like to keep this a constant at http://localhost:8081/log4jdemo
> only.
> I am using both a href and html:link.
> 
> But, even in cases where i use direct action like /loginScreen.do, on 
> invoking the action, i.e clicking a button,
> i get the full  path in the url.
> 

As others have suggested, using frames is an easy way to leave a constant URL
showing in the location bar.  It works even if you have a  with only
one frame in it.

Another alternative would be to use a little JavaScript to open a window that
does not have a location bar, and run your app there.

> This exposes the data to the hackers and will be a big issue in deployment.
> 

I hope you understand that neither of the above techniques, nor pretty much any
other hiding technique, will do the slightest bit of good at protecting
knowledge of the URLs being used from hackers?  The client browser (or
application, since hackers have been known to write HTTP client apps that try
to act like a browser) sees all the real URLs.  So will anyone who can do a
View Source on the actual HTML.

Controlling the URL in the location bar for aesthetic reasons is fine.  Assuming
that this would improve the security of your application is a bad mistake.

> Any help will be appreciated.
> 
> Richie
> 

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ServletContext/Cluster

2004-01-24 Thread Craig R. McClanahan
Quoting Mohan Radhakrishnan <[EMAIL PROTECTED]>:

> Hi
>I read the following spec. This means that in a clustered environment the
> application scope
> is useless.

Not true at all.

. I can't really believe this. Why do we have this scope then ?
> 

A primary purpose for appication scope variables is to store an in-memory cache
of read-only data that is repeatedly used, but is shared across all users (for
example, an array of LabelValueBeans containing U.S. state appreviations and
their corresponding names).  Typically, the data for such a cache is loaded
(from a database, or from properties files, or whatever) either at application
startup, or lazily loaded the first time it's requested.

This approach works fine in either a single-server or multi-server environment,
and will improve the response time of your application (by avoiding repeated
database loads of the same data) in either scenario.  The fact that the same
physical instance of the in-memory objects is not shared doesn't matter -- an
appication receives the right data value no matter which server instance it is
running inside, because all the copies are duplicates.

For non-read-only-shared-data scenarios, you need to heed Section SRV.3.4.1:

When information needs to be shared between
servlets running in a distributed environment,
the information should be placed into a session
(see Chapter SRV.7, "Sessions"), stored in a
database, or set in an Enterprise JavaBeans component.

For other issues related to running applications in a distributed environment,
see SRV.2.2 and SRV.7.7.2.  One of the most important features of session
management is that the container is *required* to serve multiple simultaneous
requests for the same session from the same server instance -- if the server
supports session migration, that can only occur "in between" requests.  Thus,
your application can be assured that the same session will not be accessed from
two server instances at the same time, which makes sessions a good place to put
mutable data that needs to be available no matter where the session is moved. 
Of course, such session attributes also have to be Serializable, but that is
generally pretty easy.

> Mohan
> 

Craig McClanahan



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Conventions for indexed properties

2004-01-22 Thread Craig R. McClanahan
Quoting "John D. Hume" <[EMAIL PROTECTED]>:

> I don't have a definitive guide, but here are some examples that could 
> be helpful.
> 

The definitive guide starts with the JavaBeans Specification:

  http://java.sun.com/products/javabeans/reference/api/index.html

you'll see that there are two variants for indexed properties -- one that has
the getter and setter methods taking an array, and one that has the getter and
setter methods taking an additional argument for the index.

There's lots of other useful info about what it means to be a JavaBean here as
well.  Just as one example, did you know that you can actually use any method
names you want (getFoo/setFoo is not required) if you're willing to build a
BeanInfo associated with your bean class?  Or that you can "hide" properties
from Struts (well, really from commons-beanutils) by creating a BeanInfo that
does not include them?

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Struts + Filter Chain = broken?

2004-01-22 Thread Craig R. McClanahan
Quoting "Richard Mixon (qwest)" <[EMAIL PROTECTED]>:

> I just came across this thread and was hoping for a little more information
> :)
> 
> I understand what Craig is saying, then given the following situation:
>  - a servlet 2.3 container (e.g. Tomcat 4.1.x);
>  - a Struts app that returns ActionForward with redirect="false";
> 
> Then a servlet filter will not be able to manipulate the response generated
> by the ActionForward (which designates a JSP).
> 
> Is the above correct?
> 

Not quite.

Let's say you have an Acton mapped to "/getData.do" that forwards to
"/generateSVG.jsp" to create the SVG output.  Ideally, you'd like to map your
filter to the "/generateSVG.jsp" URL because that is the generator of the
output that is actually being filtered.  And you can do that in Servlet 2.4 if
you specify in the filter mapping that it applies to forwards.  But this is the
part that isn't supported in a Servlet 2.3 environment.

However, if you map your filter to "/getData.do" instead, it will work -- from
the perspective of the filter, it does not know or care how many forwards you
do inside the servlet to create the response, it just processes whatever
response is returned.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Session Problem

2004-01-21 Thread Craig R. McClanahan
Better late than never (hot cpu chip literally fried a motherboard) ...

Quoting Andrew Hill <[EMAIL PROTECTED]>:

> 
> How do I make sure the session on both the browsers will be different other
> than URL Rewriting.
> 
> 

For Netscape (and I presume Mozilla but haven't checked), I don't believe there
is any way to do this.  For IE, there's a configuration setting called "Browse
In New Process" or something like that which makes each window collect its own
pool of cookies, rather than sharing them.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: redirecting to fully qualified hostname

2004-01-13 Thread Craig R. McClanahan
Quoting "Fullam, Jonathan" <[EMAIL PROTECTED]>:

> All,
> 
> The application I am working on is secured with a login that required a
> username and password.  Once a user is logged in, all pages can be accessed
> as long as there is a Subject object in the Session.  My problem is that
> part of the webapp provided links to pages that open in another window, and
> when the link is clicked, it is forwarding to the logon page as if the
> Subject object is no longer in the Session.  I've determined that this
> behavior is only present when the hostname used for the request is not fully
> qualified upon the intial logon.
> 

This is really a question for your servlet container provider, since it's not
Struts specific.  It's up to the server configuration whether "serverName" and
"serverName.mycompany.com" are considered to be the same virtual host or not
(which would be a prerequisite to sharing the session).  A couple of approaches
to consider:

* If your webserver considers the two to be different,
  put a redirect on one so that you always end up on the other.

* Construct all your hyperlinks without the "http://host"; part,
  and just start with a slash followed by the context path.
  That way, the browser will reconstruct an absolute URL
  using the server name (qualified or not) that came in on
  the original request.

Craig

> For instance.
> 
> User logons on by going to http://serverName/webapp/logon.do
> 
> Then the application provides a link to
> http://serverName.mycompany.com/webapp/something.do which open a page in a
> new window.
> 
> When the user click the link, a new window is opened but they are forwarded
> to the logon page as if they never logged on in the first place.
> 
> How can I have all requests to the original hostname
> http://serverName/webapp be redirected to
> http://serverName.mycompany.com/webapp ?  Is there anybody out there that
> has experienced this or knows of a better way to work around this issue?
> 
> Thanks in Advance,
> Jonathan
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: handling form based authentication w/ remember-me cookie

2004-01-13 Thread Craig R. McClanahan
Quoting [EMAIL PROTECTED]:

> 
> Are Servlet filters supposed to be called for both GET and POST
> methods? They seem to be getting called for GETs only on Tomcat 5.
> -Chris

For filters mapped to ordinary application URLs, the filter should indeed get
mapped on both GET and POST methods.  For filters you attempt to put on
"/j_security_check" you are totally outside the bounds of the servlet
specification, and the only thing you can assume is that the behavior is
undefined.

Personally, I consider it a bug that Tomcat 5 invokes filters on this, even if
it's just on a GET.

Craig McClanahan


> 
> 
> > -Original Message-
> > From: Parmar, Dipakkumar [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, January 13, 2004 03:57 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: handling form based authentication w/ remember-me cookie
> > 
> > Hi Max,
> > 
> > I haven't tested it either.  I read it about this in "IBM WebSphere V5.0
> > Security handbook (page 64)".
> > 
> > Regards,
> > Dipak Parmar
> > 
> > 
> > -Original Message-
> > From: Max Cooper [mailto:[EMAIL PROTECTED]
> > Sent: Monday, January 12, 2004 10:42 PM
> > To: Struts Users Mailing List; [EMAIL PROTECTED]
> > Subject: Re: handling form based authentication w/ remember-me cookie
> > 
> > 
> > Dipak,
> > 
> > Are you certain that the filter will be invoked on the /j_security_check
> > request when container-based security is used? I have not tested this, but
> > it would not surprise me to find that some containers do not execute
> filters
> > on /j_security_check requests. I don't know if the Servlet Spec says
> > anything about this case.
> > 
> > Chris,
> > 
> > Another alternative to the original problem of security with "remember me"
> > functionality will be available soon. A patch has been submitted to my
> > SecurityFilter project (http://www.securityfilter.org/) to support
> "remember
> > me" functionality. The integration should be complete soon, and a beta
> > release will be made available once the integration is complete.
> > SecurityFilter works very much like container-managed security otherwise,
> > including the configuration format (except that you declare the
> constraints
> > in a separate config file rather than web.xml).
> > 
> > -Max
> > 
> > - Original Message -
> > From: "Parmar, Dipakkumar" <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > Sent: Monday, January 12, 2004 7:43 AM
> > Subject: RE: handling form based authentication w/ remember-me cookie
> > 
> > 
> > > Hi Chris,
> > >
> > > You can do this using Servlet Filter.  What you need to do is write
> > > postLoginFilter that maps to the j_security_check url.
> > >
> > > In doFilter method, you can write your post login code after
> > > j_security_check done is work.
> > >
> > > Something like:
> > > public void doFilter(.)
> > >
> > > // let the j_security_check to do it's work
> > > chain.doFilter(request, response)
> > >
> > > // do you post login stuff here
> > >
> > > Regards,
> > > Dipak Parmar
> > >
> > >
> > >
> > > -Original Message-
> > > From: Chris Ruegger [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, January 12, 2004 9:53 AM
> > > To: Struts Users Mailing List
> > > Subject: handling form based authentication w/ remember-me cookie
> > >
> > >
> > > I am using Struts and building a logon page to do Form-based
> > authentication
> > > under Tomcat. I want to also have a checkbox for the user to check that
> > says
> > > "remember me" so that I can send them a cookie.  I'm not sure how to
> > > "intercept"
> > > the form values because I have to post to j_security_check. How can I
> get
> > > the
> > > check-box value, set up the cookie, and send them to j_security_check
> with
> > > struts?
> > >
> > > Thanks
> > >
> > >
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > 
> > 
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: handling form based authentication w/ remember-me cookie

2004-01-13 Thread Craig R. McClanahan
Quoting Matt Raible <[EMAIL PROTECTED]>:

> Remember Me functionality with j_security_check has worked fine for me. 
>   I just go to a LoginServlet from my loginForm, which sets cookies and 
> redirects to j_security_check.  Then I map a Filter to check for those 
> cookies and logs the user in appropriately.  More with code at:
> 
> http://www.mail-archive.com/[EMAIL PROTECTED]/msg86636.html
> 
> Complete code is available in my AppFuse application at:
> 
> http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuse
> 
> HTH,
> 
> Matt
> 

Filters are *not* required to be invoked on j_security_check invocations.  In
fact, Tomcat won't even enable the "j_security_check" url unless an
unauthenticated user accesses a protected resource.  Basically, I believe there
is no guaranteed-to-be-portable way to implement "remember me" functionality on
the server using container managed security.

Craig



> On Jan 12, 2004, at 8:41 PM, Max Cooper wrote:
> 
> > Dipak,
> >
> > Are you certain that the filter will be invoked on the 
> > /j_security_check
> > request when container-based security is used? I have not tested this, 
> > but
> > it would not surprise me to find that some containers do not execute 
> > filters
> > on /j_security_check requests. I don't know if the Servlet Spec says
> > anything about this case.
> >
> > Chris,
> >
> > Another alternative to the original problem of security with "remember 
> > me"
> > functionality will be available soon. A patch has been submitted to my
> > SecurityFilter project (http://www.securityfilter.org/) to support 
> > "remember
> > me" functionality. The integration should be complete soon, and a beta
> > release will be made available once the integration is complete.
> > SecurityFilter works very much like container-managed security 
> > otherwise,
> > including the configuration format (except that you declare the 
> > constraints
> > in a separate config file rather than web.xml).
> >
> > -Max
> >
> > - Original Message -
> > From: "Parmar, Dipakkumar" <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > Sent: Monday, January 12, 2004 7:43 AM
> > Subject: RE: handling form based authentication w/ remember-me cookie
> >
> >
> >> Hi Chris,
> >>
> >> You can do this using Servlet Filter.  What you need to do is write
> >> postLoginFilter that maps to the j_security_check url.
> >>
> >> In doFilter method, you can write your post login code after
> >> j_security_check done is work.
> >>
> >> Something like:
> >> public void doFilter(.)
> >>
> >> // let the j_security_check to do it's work
> >> chain.doFilter(request, response)
> >>
> >> // do you post login stuff here
> >>
> >> Regards,
> >> Dipak Parmar
> >>
> >>
> >>
> >> -Original Message-
> >> From: Chris Ruegger [mailto:[EMAIL PROTECTED]
> >> Sent: Monday, January 12, 2004 9:53 AM
> >> To: Struts Users Mailing List
> >> Subject: handling form based authentication w/ remember-me cookie
> >>
> >>
> >> I am using Struts and building a logon page to do Form-based
> > authentication
> >> under Tomcat. I want to also have a checkbox for the user to check 
> >> that
> > says
> >> "remember me" so that I can send them a cookie.  I'm not sure how to
> >> "intercept"
> >> the form values because I have to post to j_security_check. How can I 
> >> get
> >> the
> >> check-box value, set up the cookie, and send them to j_security_check 
> >> with
> >> struts?
> >>
> >> Thanks
> >>
> >>
> >> -
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Included port numbers in web links e.g. 8080

2004-01-09 Thread Craig R. McClanahan
Quoting "Gabriel W." <[EMAIL PROTECTED]>:

> Hi,
> 
> I am relatively new to this list so I do not know if this topic was discussed
> before (I checked the archive and it does not appear that way).
> 
> It seems that Struts includes the ServerPort in web links if not of the
> values 80 or 443 (e.g. http://mydomain.com:8080). In some cases this is not
> the welcomed behavior.
> Specifically if the Struts server is listening on Port 8080 behind a
> firewall. The firewall receives the request from the outside
> internet on port 80 and routes it to the machine listening on Port 8080.  
> 
> The Struts machine in this case does not know the difference and so includes
> the Port 8080.
> 
> I looked at the Struts source code I assume is behind the logic
> (org.apache.struts.taglib.html.BaseTag), and it
> does not appear as though there is a configuration flag to turn this logic
> on/off.
> 
> Are there any considerations for such an option in the future so that a
> firewalled site won't have to show 8080.
> 
> NOTE: This is a situation where the Struts server does not have permission to
> listen on Port 80.
> 
> Regards,
> Gabe
> 

Struts is basing its decision on the port returned by calling
ServletRequest.getServerPort() -- in other words, if you've got a server or
proxy that receives requests on port 80 and internally redirects them to some
other port, there's absolutely no way that Struts can know what the right port
number is unless your servlet container can tell it.

For situations like Tomcat running behind an Apache HTTPD server, this normally
gets taken care of you automatically.  If you've got a different situation,
you'll need to figure out how to tell your servlet container to adjust the
server port it reports -- there's nothing Struts can do to help.

Craig McClanahan




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Action to JSP

2004-01-09 Thread Craig R. McClanahan
Quoting Geeta Ramani <[EMAIL PROTECTED]>:

> The easiest way is perhaps to simply add a "redirect=true" in your action
> mapping.  However, be aware that this will kill your request attributes
> (since your request
> object is no longer forwarded..)
> 

Geeta's warning about one consequence is quite correct.  So is the warning that
you're going to make the performance of your application worse, because a
redirect requires an extra round trip to the client (a forward is basically a
glorified subroutine call that happens only on the server, which is why the
browser doesn't change it's address -- it never knew what happened).


In a web *applicaton* (as opposed to a web *site*), URLs should be thought of as
an internal implementation detail, not a primary user-accessible feature.  If
you find your users getting distracted by the displayed URLs (or, worse, trying
to bookmark them, which will never work unless your app takes pains to make it
work), consider creating a frameset with a single frame in it (so the shown
address never changes), or use JavaScript to create a new window that does not
have a location bar.

Other folks will disagree with me on this, of course, but in my general response
is "show me where the back button and bookmarks window are in a Swing app, and
I'll make them available in my web app."  :-)


> Regards,
> Geeta
> 

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tiles with XML and XSL

2004-01-09 Thread Craig R. McClanahan
Quoting Tin Pham <[EMAIL PROTECTED]>:

> Wow that great Craig. Thanks for taking the time to give me some hints.
> 
> I did not know that the servlets 2.4 would let me do that. I really like
> that one. I can then have pockets of xml on my page. I will check this
> option out first.
> 

Filters on request dispatcher calls are very cool ... but my absolute favorite
feature of the new technologies (Servlet 2.4 and JSP 2.0) is that you can now
use EL expressions everywhere in a JSP page, not just in tag attributes of tags
that understand them (like JSTL tags, and the struts-el tags).

This applies to the "do an XSLT transformation" scenario quite nicely, once you
remember that a JSP 2.0 page can be an XML document (or an XML document can be
a JSP 2.0 page, depending on how you want to look at it :-).  Just as an
example of this, I've been playing with an application that grabs news items
from a database and renders them in RSS ... the cute trick being that the
client can request whichever RSS version they want.  I did this by having the
output from the app be a JSP page in a fairly generic format:

  http://java.sun.com/jstl/core";
   about="${channel.aboutURL}">
  ${channel.title}
  ${channel.linkURL}
  
${channel.description}
  
  ... more per-channel stuff ...
  
  
  
  ${item.title}
  ${item.linkURL}
  
  ${item.description}

... more per-item stuff ...
  
  
  

and used a different stylesheet to reformat this to 0.9, 0.91, 1.0, or 2.0
standards.  The EL expressions pulled in the dynamic parts of the data from my
channel and item beans, with the static parts forming the standard structure of
my generic XML (with elements and attributes set up the way my stylesheets
expect them).  If you're not an XSLT guru, it would also be pretty easy to
create a different JSP page for each of the four supported RSS versions, and
use something like a different ActionForward for each of them to select the
version.

This is a *ton* easier than dynamically constructing XML in Java :-).

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: configuration is frozen

2004-01-08 Thread Craig R. McClanahan
Quoting Lucas Halim <[EMAIL PROTECTED]>:

> Thanks Hubert.
> 
> Anybody knows why is it frozen at the first place? Is that just another mod
> in Struts 1.1?
> 

Without freezing the configuration, two bad things would happen:

* We'd have to synchronize around all accesses to the
  HashMap instances inside the configuration beans that
  are accessed on every request, causing a performance hit.

* It would be way too easy for applications to accidentally
  modify the configured information, and thereby introduce
  very mysterious and hard to find bugs.

> Lucas

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Configuring Struts NOT to create (unauthentified) sessions

2004-01-08 Thread Craig R. McClanahan
Quoting Nicolas De Loof <[EMAIL PROTECTED]>:

> I've made a grep on Struts 1.1 sources. I noticed some case where a session
> is created that seems to me 'uncontroled' :
> 
> 
> RequestProcessor uses request.getSession() :
> - in processLocale if controller is configured to use Locale (default =
> true)
> 
> HTMLTag uses request.getSession() :
> - in currentLocale() : if any JSP uses  a session is created !
> 
> o.a.s.validator.Ressouces uses request.getSession() :
> - in getLocale(request) : If validator is used (for example to validate login
> page) a session will allways be created
> 
> 
> Isn't they're any way NOT to create a session for a user that hasn't been
> authentified ?
> 
> Nico.
> 

Besides the places where Struts itself creates a session, if you're using JSP
you should be aware that every JSP page will create a session unless you tell
it not to:

  <%@ page session="false" %>

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: BeanUtils use in struts

2004-01-08 Thread Craig R. McClanahan
Quoting Marco Mistroni <[EMAIL PROTECTED]>:

> Hi Craig,
>   Thanx for your comments.
> 
> >It uses reflection on POJOs (plain old Java objects) but not on
> DynaBeans ->- the
> > implementation inside DynaActionForm is a HashMap with typesafe
> getters >and
> >setters.
> 
> In my case I have a Custom DTO with setter/getters and a Form bean that
> extends DynaActionForm (with properties declared in struts config).
> 
> However, BeanUtils.copyProperties()  works for calling  both
> BeanUtils.copyProperties(form,dto) and 
> For BeanUtils.copyProperties(dto, form) ...
> 
> Is it supposed to work like that, or is it weird that it's working in
> both
> Ways when I have a DynaActionForm?
> 

Yes it is supposed to work that way.  Inside the PropertyUtils methods, it looks
at the origin and destination beans individually, and uses reflection (or not)
based on that.  So, any combination of POJO and DynaBean works.  In addition,
your origin object can also be a Map (although currently the destination cannob
be).

> Thanx and regards
>   marco
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: server hangs after finite number of requests

2004-01-07 Thread Craig R. McClanahan
Quoting Heather Marie Buch <[EMAIL PROTECTED]>:

> On Wed, 7 Jan 2004, Manfred Wolff wrote:
> 
> > Heather.
> > 
> > I user dbcp since one year in a productive system with mysql and have no 
> > problems yet. The best documentation in my mind is the original from 
> > tomcat. There are all parameters explained:
> > 
> >
>
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
> 
> Thanks very much for pointing me here. This is a good explanation of where
> the dbcp configuration goes. I had been looking at this page
> 
> http://jakarta.apache.org/commons/dbcp/configuration.html
> 
> which gave me the configuration parameters, but didn't explain where to
> put them. They should provide a link from the dbcp page to that tomcat
> page!

I suppose you could, but keep in mind that commons-dbcp can be used in any
servlet container -- it is not specific to Tomcat (whereas the instructions I
pointed you are very much Tomcat specific).

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta Reference Implementation

2004-01-07 Thread Craig R. McClanahan
Quoting virupaksha <[EMAIL PROTECTED]>:

> Dear Craig,
> 
> 
> I am working on resin-2.1.9 (java page container from caucho),
> It's supports servlets 2.3 version, can i  use JSF for this container,
> 

It should indeed be able to run JavaServer Faces I've never tested in that
environment, but I know some others have).  However, compile errors don't have
anything to do with the server -- they have to do with how you are setting up
your class path for compilation.  The build.xml file used here (in
contrib/struts-faces) lets you customize things by:

* Copy build.properties.sample to build.properties

* Change any paths in build.properties to match your own system's
  installation paths.

Craig

> Regards,
> Viru
> 
> - Original Message -
> From: "Matthias Wessendorf" <[EMAIL PROTECTED]>
> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> Sent: Tuesday, January 06, 2004 5:16 PM
> Subject: RE: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta
> Reference Implementation
> 
> 
> hi jan,
> 
> perhaps you must change the sturcuture of build.xml
> 
> in my case:
> i copied jsf-1.0 beta in to $jwsdp.home
> and copied some specified lib into $jwsdp.home too.
> 
> e.g. jsp-api, servlet-api
> 
> of course i copied jsf-libs and jstl-libs to WEB-INF/lib of example2
> now tomcat started them up...
> 
> and perhaps you must change your user-name/password for tomcat! :-)
> 
> try this...
> 
> greetings
> matthias
> 
> 
> 
> -Original Message-
> From: Jan Dirksen [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 06, 2004 10:02 AM
> To: Struts Users Mailing List
> Subject: Re: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta
> Reference Implementation
> 
> 
> Hi Craig,
> 
> i just want to try the struts-faces examples.
> but i got compilation-error. is there something i
> need...?
> jwsdp-1.3 is on my box.
> 
> thanks
> 
>  --- "Craig R. McClanahan" <[EMAIL PROTECTED]>
> schrieb: >
> >
> > I'm pleased to announce that the Proposed Final
> > Draft version of the JavaServer
> > Faces 1.0 Specification, and a corresponding Beta
> > release of the Reference
> > Implementation, is now available at:
> >
> >
> >
> http://java.sun.com/j2ee/javaserverfaces/download.html
> >
> > Please send any feedback and comments strictly about JavaServer Faces
> > to <[EMAIL PROTECTED]>.
> >
> > I'm also finishing up an update to the Struts-Faces Integration
> > Library, and will be making it available (via nightly builds)
> > very soon.  Feel free to ask
> > any questions about how to use Struts and JavaServer
> > Faces here on the
> > STRUTS-USER list.
> >
> > Craig McClanahan
> >
> >
> >
> -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> >
> 
> __
> 
> Gesendet von Yahoo! Mail - http://mail.yahoo.de
> Logos und Klingeltöne fürs Handy bei http://sms.yahoo.de
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: BeanUtils use in struts

2004-01-07 Thread Craig R. McClanahan
Quoting Marco Mistroni <[EMAIL PROTECTED]>:

> Hi all,
>   I have a  question about using BeanUtils in Struts.
> For saving me from writing lot of code, I am using DynaActionForms in my
> pages.
> In the backend, I have some DTOs, so I decided in order to make
> My app more 'extensible' without rewriting too much code, to use
> BeanUtils to populate my DTOs with values from DynaActionForm, and to
> Use the same mechanism to populate DynaActionForm from DTO.
> 
> Now, pls correct me if I am wrong, but BeanUtils uses reflection in
> Order to populate properties..

It uses reflection on POJOs (plain old Java objects) but not on DynaBeans -- the
 implementation inside DynaActionForm is a HashMap with typesafe getters and
setters.

> I have read from some books ('Effective Java') that using reflection
> Is much slower than invoking methods normally..
> In my app,

Depends totally on what JVM you are using -- the answer changes with every
version.  Whether it's visible to you (in terms of increased response time) is
even more variable, but in most web based environments the database is the
primary cause for delays, followed by network traffic.  The only way that
reflection can make any difference at all is if you're CPU bound on your web
tier server.

> I will gain flexibility (I don't need to write methods for
> Populating dtos from form and vice versa), but am I going to lose much
> In tems of performance?
> 

Depends on your application environment (as described above), but it's pretty
unikely to cause a problem -- especially if you use dynabeans, which don't use
reflection at all :-).

> Anyone can give his comments?  I think BeanUtils is of great help,and it
> would be a pity to give up the benefits that I get from it...
> 

The only way to know if this matters in your application is to benchmark your
application.  But there are thousands of Struts-based webapps in the world,
many using traditional ActionForms (and therefore heavily dependent on
reflection).

Aiming for "fastest possible" is the wrong target.  Aiming for "fast enough"
lets you focus on other goals about your app (less code, easier maintenance,
and so on) also.

> Best regards
>   marco
> 

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tiles with XML and XSL

2004-01-07 Thread Craig R. McClanahan
Quoting Tin Pham <[EMAIL PROTECTED]>:

> Hi,
> 
> I am wondering if anybody here has mulled over the idea of using XML and XSL
> with Tiles.
> 
> Right now I have a great application that makes use of Struts 1.1 with a
> role based layout using Tiles. It uses the common layout we see everywhere,
> header, dynamic menu, footer and of course body.
> 
> I started thinking that it would be nice to put all the content of the body
> tile into an XML file. Just the content though. Including forms and buttons
> might not be a good idea at this stage. Simpler would be better as my team
> is still learning to be proficient with Struts.
> 
> Googled of course and did not find much.
> 
> The two approaches I am considering are,
> 
> 1)
> Change the reference in the tile definition of body=myContent.jsp to a kind
> of composition servlet which recieves as paramaters, the xml and xslt file
> to output as html (with this approach I would have to include the forms and
> buttons).
> 

This is certainly a feasible approach.


If you are running in a Servlet 2.4 (i.e. J2EE 1.4 or Tomcat 5) environment, you
also have an additional choice -- in Servlet 2.4 you can specify that filters
get invoked on RequestDispatcher.include calls (which is what Tiles does under
the covers).  Therefore, you can create a (servlet or JSP based) Tile whose
reference URL points at an XML-based resource, and then (based on URL-specific
filter mappings) apply an XSL transformation in the filter that is appropriate
for this particular tile.

> 2)
> Make a reference to my xml and xslt server side using a custom tag in the
> jsp page.
> 

This is definitely a feasible solution.  But don't bother trying to create such
tags yourself -- there are robust capabilities for this available in the JSP
Standard Tag Library (JSTL).  An open source implementation of JSTL is
available in the "standard" tag library of the Jakarta Taglibs project:

  http://jakarta.apache.org/taglibs/

> 3)
> Figure out a way to render this client side relying on the browser.

In an intranet environment where you control the client browser software, this
can be a practical approach.  For an Internet-based app, have fun with the
customer support calls :-).

4) There are some third party Struts add-ons available that address the notion
of using XML and XSLT technologies alongside Struts -- check the resource pages
for links.

> 
> 
> Any thoughts or links to resources would be greatly appreciated.
> 
> 

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta Reference Implementation

2004-01-06 Thread Craig R. McClanahan
Quoting Jan Dirksen <[EMAIL PROTECTED]>:

> oh good morning...
> thank you! :-)
> 
> okay i can deploy it via tomcat-manager
> 
> but when i start the jsf-cardemo
> i got this error:
> 
> org.apache.jasper.JasperException: This absolute uri
> (http://java.sun.com/jstl/core) cannot be resolved in
> either web.xml or the jar files deployed with this
> application
> 
> very strange.
> the struts-jsf works, but not "core" jsf...
> 
> do anyone know?
> i am using tomcat version 4.1.27
> or must i use tc 5.X for JSF?
> 

I've had my share of grief with 4.1, and always use 5.0 now.  There are some
potential workarounds to 4.1 problems listed on the JavaServer Faces release
notes and web pages.

One thing to note with *any* standalone Tomcat usage is that JavaServer Faces is
not "built in" the way it is with JWSDP, so you'll need to include all the
needed JAR files in your /WEB-INF/lib directory.  Don't even bother to try to
"install" JavaServer Faces into common/lib on Tomcat 4.1 -- it flat won't
work.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta Reference Implementation

2004-01-06 Thread Craig R. McClanahan
Quoting Jan Dirksen <[EMAIL PROTECTED]>:

> Hi Craig,
> 
> i just want to try the struts-faces examples.
> but i got compilation-error. is there something i
> need...?
> jwsdp-1.3 is on my box.
> 

Without knowing the details of your error messages, it's pretty difficult to
tell exactly what is going on, but most compilation problems are caused by not
setting up a "build.properties" file correctly.  The simplest way to do that is
to copy "build.properties.sample" to "build.properties" and modify the settings
as needed.

On the other hand, to simply execute the examples, you don't need to compile at
all -- just follow the instructions in the README.txt file to add jsf-api.jar
and jsf-impl.jar to the web application, and deploy it like any other.  (You'll
also have to remove the EA release of JavaServer Faces from JWSDP since the
current code uses the beta release).

> thanks

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Doubts about FacesRequestProcessor on struts-faces

2004-01-05 Thread Craig R. McClanahan
Quoting Diego Louzán Martínez <[EMAIL PROTECTED]>:

> Ok, I suppose this is a direct question to Craig as the maintainer
> ofstruts-faces:I'm studying JSF and I need to integrate a Struts
> application with it,so I am studying struts-faces too. My problem is
> that this applicationuses a custom RequestProcessor that implements the
> ProcessingFilterpattern and in the *KNOWN LIMITATIONS* of struts-faces
> it says that Ihave to subclass FacesRequestProcessor (I'm not using
> Tiles). Thequestion is: ¿this behaviour is planned to be stable? ¿will I
> have tochange the implementation later? I will also be grateful for some
> adviceon how to do it.Thanks in advance.
> -- 

For use with Struts 1.1, this behavior is indeed planned to be stable -- you
should plan on subclassing FacesRequestProcessor (if you're not using Tiles) or
FacesTilesRequestProcessor (if you are).  As of the latest nightly builds of
the struts-faces library, you specify your overridden class name in the usual
way (with the  element in struts-config.xml).

At some point during the development of Struts 1.2 and 2.0, we'll switch our
primary approach to something like commons-chain (see this package in the
Jakarta Commons Sandbox, and the source code in the "contrib/struts-chain"
directory of the Struts source archive, to get a feel for where we're going). 
At that point, you will be able to configure and customize your own processing
chains based on the combination of technologies that you are using, without
having to explicitly subclass a monolithic RequestProcessor base class.

In terms of mechanics, it's really no different than subclassing the standard
RequestProcessor -- simply create a class that extends the base one, and
override the methods you need to change.  You'll need struts-faces.jar on your
compile classpath, of course.

> Diego Louzán Martínez
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Problem with BeanUtils.copyProperties()

2004-01-02 Thread Craig R. McClanahan
Quoting Patrick Scheuerer <[EMAIL PROTECTED]>:

> If there are multiple methods with the same name, shouldn't copyProperties()
> pick the one with the same method signature as in the source bean??? In my 
> opinion this would at least be a desirable default behavior

No, it shouldn't.

BeanUtils uses the standard JavaBeans introspection logic of the JDK to
determine what the legal property names are, and what the getter and setter
method names are (the default is getFoo and setFoo, but that can be changed). 
If you have two setters with the same name (but a different parameter type),
then -- by definition -- this is not a JavaBeans property so it will be ignored
by BeanUtils.

See the JavaBeans Specification for more information:

http://java.sun.com/products/javabeans/reference/api/index.html


> 
> Patrick
> 

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: .NET: We are just like Struts... only better.

2003-12-30 Thread Craig R. McClanahan
Quoting "Hookom, Jacob" <[EMAIL PROTECTED]>:

> As a follow up to your "by hand" comment, isn't Sun developing a new GUI
> development tool to wizard-ize JSF?
> 

Yes:  http://wwws.sun.com/software/products/jscreator/index.html

Even if it weren't a product coming from the company I work for :-), this one
would have me tempted ...

Many other companies are promising support for JavaServer Faces in the near term
as well.

> Speaking of wizards, can JSF enforce flow in a wizard manner without
> additional modifications like Struts?

Depends on what you mean by "enforce" -- Struts doesn't really do anything to
enforce flows.  However, both Struts and JavaServer Faces share the concept of
decoupling the actual name of the page to be displayed next from the business
logic that returns an outcome which the navigation decision is based on.  In
Struts you do this by using  declarations at the global or per-Action
level.  In JavaServer Faces, you do this by defining navigation rules based on
the page you're currently on, the action method that was called (i.e. which
submit button was pushed), and what the logical outcome value was returned by
the action method.

> 
> Thanks much!
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Still having problems with File upload (multipart-formdata)

2003-12-30 Thread Craig R. McClanahan
Quoting Patrick Scheuerer <[EMAIL PROTECTED]>:

> Matthias Wessendorf wrote:
> 
> > Hi Patrick,
> > 
> > you want to get the path of /myapp 
> > like C:\Tomcat\webapps\myapp
> > or?
> 
> That's exactly what i was trying to do!
> 
> > in an actionClass
> > you now want to store
> > in placeString\uploaddir
> > isn´t it?
> 
> Right again :-)
> 
> > i wrote an Util-Class which managed the
> > storage in my action.
> > one parameter is the formfile the other the placeToStore.
> > you can get it, if you want...
> 
> That would be wonderful! Thank you very much for your help!
> 

I would also offer a couple of cautions about this approach:

* You are not guaranteed that a particular servlet container
  even *has* a concept of a directory in which the web app
  is deployed -- for example, even Tomcat can execute a webapp
  directly from the WAR file.  When you do that, getRealPath()
  returns null instead of a pathname, and your calculations above
  will trigger a NullPointerException.

* Even when you know that your apps are being deployed in unpacked
  directories, uploading things directly into that directory means
  you have to be careful about redeployment when you update the app
  -- the normal behavior of "delete the old directory and replace it
  with the new app" wipes out any uploaded files.

I would recommend defining a directory somewhere in your server to hold the
uploaded files for a webapp, and then pass the pathname of this directory to
your app as a context init parameter or something like that.  This approach
deals with both of the problems identified above.

> Patrick
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: .NET: We are just like Struts... only better.

2003-12-30 Thread Craig R. McClanahan
Quoting Paul Thomas <[EMAIL PROTECTED]>:

> 
> On 29/12/2003 03:40 Curtis Taylor wrote:
> > This brings up an interesting point (for me, at least): Is anyone on
> > this list developing under Linux w/XEmacs or Emacs? I'm curious as to
> > whether I'm living in the past or not...;-)
> 
> You're in good company . I'm using Linux and Emacs/JDE. That's the nice 
> thing about Java development - you can usually choose the tools which suit 
> you :)
> 

For what it's worth, nearly all of my personal development work on Struts has
been, and continues to be, done with XEmacs and Linux ... as does my
development work on JavaServer Faces.  It's important to me personally that
iconoclasts can still use this stuff to develop applications "by hand".  :-)

> -- 
> Paul Thomas

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JSF managed beans

2003-12-30 Thread Craig R. McClanahan
Quoting Nadeem Bitar <[EMAIL PROTECTED]>:

> 
> Where and how do Managed Beans and JSF's navigation rules fit in a
> struts/jsf application?
> 

It depends on whether you want all (or part) of your application to migrate to a
JSF for the "controller" type features or not.

In a pure-Struts app that is being modified to use JSF components, you probably
won't use the JSF navigation rules very much -- your decision to stay with the
Struts controller and Action architecture implies that you still want to use
Struts facilities for managing the navigation (forwards and such), so they
won't do you much good.  The managed bean facilities are useful (even here) to
load "backing beans" -- event handlers for UI events, such as the
"RegistrationBacking" class in the example program that's included in the
current nightly builds:

  http://cvs.apache.org/builds/jakarta-struts/nightly/struts-faces/

and managed beans are useful generally if you start using ValueBinding and
MethodBinding APIs programmatically in your own code (very easy to do).  You
don't need to worry about the form bean itself, though ... that gets created on
demand for you in the same way that standard Struts does it.

With the newest beta, it is also possible to have an intermixed application that
uses the Struts controller architecture for part of the app, and use JSF
faclities for the remainder.  In that scenario, you would of course be using
managed beans and the JSF navigation rules for the JSF-based portion of the
app.   In general, though, I'd recommend sticking with one controller
architecture for any partcular application, and think of this as primariy a
transition assistance facility.

Craig


> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Boolean checkbox in session form

2003-12-29 Thread Craig R. McClanahan
Quoting Tim Lucia <[EMAIL PROTECTED]>:

> Care to share?  This would be a very, very useful extension.
> 
> Is there any plan(s) for future Struts release(s) to support some
> attribute of this sort?  Something like "forceFalse='true'" or
> "forceValue='true'".
> 
> Tim
> 

Guillermo is trying work too hard.

The standard approach to dealing with boolean form bean properties (presented by
a checkbox) is to set the boolean property to false in the reset method of your
form bean, which is called every time the form is submitted.  If the user
checked the box, then the property will be set to true in processPopulate().

Now, if you want to reset the property again before forwarding back to the same
page again (so that it's always rendered as unchecked when the page is
displayed), just have your Action set the boolean property to false.  That is
what controls how the checkbox is rendered -- in EXACTLY the same way that an
Action can preconfigure any other form field by setting the corresponding form
bean property before fowarding to the page.

Craig McClanahan


> > -Original Message-
> > From: Guillermo Meyer [mailto:[EMAIL PROTECTED] 
> > Sent: Monday, December 29, 2003 4:40 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Boolean checkbox in session form
> > 
> > 
> > To solve this problem, i created a new taglib for checkbox 
> > (extending BaseFieldTag), that creates a hidden input with a 
> > value of true|false and an auxiliary checkbox (named as 
> >  + _chk) with a javascript handler that checks 
> > on checkbox value to set true or false to the hidden field, 
> > so always is posted a true or a false value from UI and set 
> > to the appropiate form attribute, and this way you can avoid 
> > reseting value in reset form.
> > 
> > -Original Message-
> > From: Franck [mailto:[EMAIL PROTECTED] 
> > Sent: Lunes, 29 de Diciembre de 2003 06:13 p.m.
> > To: 'Struts Users Mailing List'
> > Subject: Boolean checkbox in session form
> > 
> > 
> > Hi,
> > 
> > I'm becoming mad ...
> > 
> > Explain : to handle ActionForm boolean properties with HTML 
> > checkbox, we "need" To initialize the property as "false" in 
> > the reset() method of the ActionForm .. Ok
> > 
> > Now, if the Action form is defined in the session scope in 
> > the struts-config file The first time the action is called, 
> > the bean is put in session scope.
> > 
> > The next time (eg submit of another form on the same page), 
> > the bean is readed from session scope 
> > (RequestProcessor.processActionForm) ... ok After that, the 
> > reset() method is called
> > (RequestProcessor.processPopulate)
> > 
> > So it's impossible to keep the boolean property as "true" 
> > 
> > How can I store the form bean in the session scope with a 
> > "true" boolean property ? Or maybe is there a way to not 
> > initialize the boolean properties as "false" (and update them 
> > with checkboxes )
> > 
> > Is my problem understandable ??
> > 
> > Thanks ...
> > 
> > Franck Lefebure
> > equipe web http://www.orangecaraibe.com
> > collaborateur http://www.synaxis-partner.com 
> mailto:[EMAIL PROTECTED]
>  
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts + Filter Chain = broken?

2003-12-28 Thread Craig R. McClanahan
Quoting Oscar Picasso <[EMAIL PROTECTED]>:

> I have a problem using filter chain with Struts
> 
> I have wrote a simple filter to use in a servlet
> filter chain for postprocessing JSP output.
> 
> It works like this:
> 
> 1. Receive request, wrap response with its own
> response wrapper, and then pass it to filter chain.
> 
> 2. The filter own response wrapper stores content in
> its own buffer when any call is made to
> response.getOutputStream().write().
> 
> 3. When request returns from filter chain - get
> content from buffer, apply an xslt transformation &
> then flush the transformed content to the original
> response.getOutputStream().
> 
> This all works fine when I request directly a JSP
> page. 
> 
> However if the JSP page is request by a struts
> forward, when the request returns from the filter
> chain - the original
> response.getOutputStream().write() never prints
> anything to the browser.
> 

In a Servlet 2.3 environment (i.e. Tomcat 4.x), filters are only applied based
on the *original* request URI (the one that selects your Action), not on the
one use to forward to a JSP page.  In a Servlet 2.4 environment (i.e. Tomcat
5.x), you can also ask for the filter to be applied on request dispatcher
calls, but you have to make this explicit:


MyFilter
myjsppage.jsp
FORWARD



> Any idea?

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Nighty Builds of Struts-Faces Integration Library

2003-12-24 Thread Craig R. McClanahan


Nightly binary builds of the Struts-Faces Integration Library, updated to work
with the new beta release of JavaServer Faces, are now available:

  http://cvs.apache.org/builds/jakarta-struts/nightly/struts-faces/

As always, the source code for this library is in the "contrib/struts-faces"
directory of the nightly Struts source distro:

  http://cvs.apache.org/builds/jakarta-struts/nightly/src/

This code is *not* ready for prime time yet, but the test application at least
works.  Tops on my list is ensuring that it works with Tiles as well ... most
likely by having two different request processor subclasses and making you
configure the one you need based on whether Tiles is in use or not.  Not quite
as transparent as the old release, but it should be able to work.

Craig

PS:  While nowhere near as cool as the gift of eternal life that we'll be
celebrating tomorrow, please consider this a Christmas gift to all the Struts
developers and users out there :-).


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] Synchronized access to application-scoped object

2003-12-24 Thread Craig R. McClanahan
Quoting Jerry Jalenak <[EMAIL PROTECTED]>:

> Craig - 
> 
> Thanks for the response.  One last question - during the time period where
> the getServletContext().setAttribute() is executing in Servlet_1, is there
> any concern about collision with an access from Servlet_2 (Struts)?  I guess
> I'm unsure whether the setAttribute() method is synchronized or not
> (the javadoc doesn't say.)
> 

You can assume that your app doesn't have to worry about calling
getServletContext().getAttribute() from one thread, and
getServletContext().setAttribute() from another thread at the same time -- the
container guarantees that the internal data structure it is using (in the case
of Tomcat, it's a HashMap that *is* synchronized appropriately) is thread
safe.

The only objects that the application has to worry about w.r.t. thread safety
are its own.

> Thanks!
> 
> Jerry Jalenak
> Development Manager, Web Publishing
> LabOne, Inc.
> 10101 Renner Blvd.
> Lenexa, KS  66219
> (913) 577-1496
> 

Craig


> [EMAIL PROTECTED]
> 
> 
> > -Original Message-
> > From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, December 24, 2003 1:00 PM
> > To: Struts Users Mailing List
> > Subject: Re: [OT] Synchronized access to application-scoped object
> > 
> > 
> > Quoting Jerry Jalenak <[EMAIL PROTECTED]>:
> > 
> > > Holiday Greetings to All!
> > > 
> > > Quick design question - Is it possible to synchronize an 
> > application-scoped
> > > object between two servlets within the same web 
> > application?  I have a
> > > servlet that I have written that maintains a List object 
> > that is stored in
> > > application scope.  This servlet basically creates a new 
> > List, then replaces
> > > the existing one (uses the same name for the object).  My 
> > second servlet
> > > (Struts) simply accesses this List in a read-only fashion - 
> > no updates.  I
> > > can write a basic spin-lock type of mechanism to ensure 
> > that my Actions do
> > > not try to access this List while my first servlet is 
> > replacing the object,
> > > but I'm wondering if there is an easier approach, possibly using a
> > > synchronized block using the application object
> > > 
> > > Comments?
> > > 
> > 
> > Synchronizing on the List instance won't help much, because 
> > of the way you're
> > replacing the old one with a new one -- but it's probably 
> > unnecessary as well,
> > since the servlet reading the old List and the servlet 
> > creating the new List
> > are never manipulating the same object instance.
> > 
> > If the servlet doing the modifying was doing it "in place" on 
> > the existing List
> > instance, then synchronizing on that instance would indeed be 
> > appropriate.
> > 
> > > TIA!
> > > 
> > > Jerry Jalenak
> > 
> > Craig
> > 
> > 
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> This transmission (and any information attached to it) may be confidential
> and
> is intended solely for the use of the individual or entity to which it is
> addressed. If you are not the intended recipient or the person responsible
> for
> delivering the transmission to the intended recipient, be advised that you
> have received this transmission in error and that any use, dissemination,
> forwarding, printing, or copying of this information is strictly prohibited.
> If you have received this transmission in error, please immediately notify
> LabOne at the following email address: [EMAIL PROTECTED]
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Synchronized access to application-scoped object

2003-12-24 Thread Craig R. McClanahan
Quoting Jerry Jalenak <[EMAIL PROTECTED]>:

> Holiday Greetings to All!
> 
> Quick design question - Is it possible to synchronize an application-scoped
> object between two servlets within the same web application?  I have a
> servlet that I have written that maintains a List object that is stored in
> application scope.  This servlet basically creates a new List, then replaces
> the existing one (uses the same name for the object).  My second servlet
> (Struts) simply accesses this List in a read-only fashion - no updates.  I
> can write a basic spin-lock type of mechanism to ensure that my Actions do
> not try to access this List while my first servlet is replacing the object,
> but I'm wondering if there is an easier approach, possibly using a
> synchronized block using the application object
> 
> Comments?
> 

Synchronizing on the List instance won't help much, because of the way you're
replacing the old one with a new one -- but it's probably unnecessary as well,
since the servlet reading the old List and the servlet creating the new List
are never manipulating the same object instance.

If the servlet doing the modifying was doing it "in place" on the existing List
instance, then synchronizing on that instance would indeed be appropriate.

> TIA!
> 
> Jerry Jalenak

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: about log4j - RE: Example of a non-threadsafe Action?

2003-12-23 Thread Craig R. McClanahan
Quoting Warren Chen <[EMAIL PROTECTED]>:

> Hi Craig,
> 
> Continue with the thread safe issue:
> 
> how about Log class? I understand that log4j itself is
> thread safe (unlike DateFormat) - but I see a lot
> examples that log4j logs are used as instance varibale
> 
> public final class MyAction
> {
> private Log log = 
> LogFactory.getLog(this.getClass().getName());
> public ActionForward execute(.)
> {.}
> }
> 

I tend to make my "log" variables static as well, but that doesn't change
whether it's threadsafe or not -- it just reduces the number of object
creations that happen if there's more than one instance of my class being
created.

> Is this thread safe?
> 

If the commons-logging implementation classes for the wrapper are threadsafe
(and they are), and the underlying logging implementation claims to be
threadsafe (as do Log4J, JDK 1.4 logging, and the SimpleLog implementation --
don't know about the others) than this is indeed threadsafe.

> If yes, then even we use instance variable, as long as
> we access it thread-safe way (ie. sync it), it will be
> ok, right? (performance is another issue)
> 

If an object is threadsafe, it should be unnecessary for you to synchronize at
all -- any required synchronzation must already be occurring inside.  For
example, consider the difference between java.util.Hashtable (which advertises
itself as threadsafe) and java.util.HashMap (which explicitly states that it is
*not* threadsafe).  The get() and put() calls never need to be synchronized in
the former case (even if you store the Hashtable in an instance variable of an
Action, because the class does its own synchronization internally.  The
opposite is true if you create a HashMap and make it accessible from more than
one thread.

For example, note that you won't see any synchronization around calls like
log.debug() or log.trace() in the Struts code.  Because the Log instance is
threadsafe, I don't need to worry about the fact that there might be two
simultaneous calls to log.debug() on different threads, processing different
requests.

In a similar vein, your servlet container guarantees that calls to
HttpSession.getAttribute() and HttpSession.setAttribute(), for example, are
thread safe ... in the sense that accessing attributes from more than one
thread will not corrupt the internal data structure that the servlet container
is using to keep track of attributes for you.  You are still on the hook, of
course, to guarantee that the objects you store as attributes are thread safe,
but that's the application's issue, not the container's issue.

Does that help?

> Thanks a lot!
> 
> Warren

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Example of a non-threadsafe Action?

2003-12-23 Thread Craig R. McClanahan
Quoting Sgarlata Matt <[EMAIL PROTECTED]>:

> What if the SimpleDateFormat variable is declared as final and/or static?
> 

How it's declared makes no difference at all.  Whether you attempt to use the
same instance simultaneously from more than one thread makes all the
difference.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Example of a non-threadsafe Action?

2003-12-23 Thread Craig R. McClanahan
Quoting Nifty Music <[EMAIL PROTECTED]>:

> Thanks Craig!  You certainly confirmed my suspicions, although I would have
> guessed that I could've gotten away with sharing the SimpleDateFormat
> variable since it wouldn't depend on any values coming in from request
> objects.  Could you perhaps shed some light on why it wouldn't make sense to
> share it?
> 

Because the internal implementation of SimpleDateFormat uses instance variables
during parsing and formatting, so it's not thread safe :-).

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Example of a non-threadsafe Action?

2003-12-23 Thread Craig R. McClanahan
Quoting Nifty Music <[EMAIL PROTECTED]>:

> Howdy all!
> 
> I was considering employing a "Master Action Class" from which I could
> inherit smaller action classes in order to make effective use of shared code.
>  However, I want to ensure that the code remains thread-safe.  Here's an
> example of what I was considering:
> 

Unfortunately, this is a pretty classic example of non-threadsafe Action code. 
Remember that there is only one Action instance in the entire web application,
shared by all requests that happen to select this action.  The problem comes
when two (or more) requests for the same action happen at the same time.

> public abstract class MainAction extends TilesAction {
> 
>   protected DynaValidatorForm form = null;
>   protected ActionErrors errors = null;
>   protected ActionMessages messages = null;   


Because these variables are declared outside of a method, they are *instance*
variables and therefore shared across requests.  That's not what you want.

>   protected SimpleDateFormat df=new
> SimpleDateFormat("MM/dd/",Locale.US); 

Although a SimpleDateFormat looks like something you ought to be able to share
successfully, it turns out this class is not threadsafe either.

>   public abstract ActionForward execute(ActionMapping mapping, ActionForm
> baseForm, HttpServletRequest request, HttpServletResponse response);
>   
>   protected boolean validLogon(HttpSession session) {
>   //check session to ensure that it's not invalidated
>   }
> 
>   protected void startSubTransaction(HttpSession session) {
>   session.setAttribute(Constants.SUB_TRANSACTION_IN_PROGRESS,
> Constants.TRUE); 
>  
>   }
>   
>   protected void endSubTransaction(HttpSession session) {
>   session.setAttribute(Constants.SUB_TRANSACTION_IN_PROGRESS,
> Constants.FALSE); 
>   }   
> }
> 
> public class SubAction extends MainAction {
> 
>   private static Logger logger = Logger.getLogger(SubAction.class);
> 
>   public ActionForward execute(
>   ActionMapping mapping,
>   ActionForm baseForm,
>   HttpServletRequest request,
>   HttpServletResponse response) {
>   
>   form = (DynaValidatorForm) baseForm;

What happens when two requests execute this statement at (essentially) the same
time?  The second assignment wipes out the first one, and you start seeing
references to the wrong form bean.

The answer is to only declare variables INSIDE your methods, and then explicitly
pass them as parameters to the methods in your subclass.

>   errors = new ActionErrors();
>   
>   if (!validLogon(request.getSession())) {
>   return (mapping.findForward("logon")); 
>  
>   }
> 
>   //Check for errors
>   if (!errors.isEmpty()) {
>   saveErrors(request, errors);
> return (mapping.findForward("error"));
>   }   
>   
>   saveToken(request); 
>   startSubTransaction(request.getSession());  
>   return (mapping.findForward("success"));
>   }
> }
> 
> What with the form, errors & messages variables being defined at class level
> in the parent class, could I run into some issues with instance variables
> being overwritten with different requests?

Absolutely.

  Should I move them into the
> individual execute() methods of the subclasses of MainAction?
> 

Or declare them in the base class's execute() method and pass them as
parameters.

> Thanks,
> 
> Brent
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: R: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta Reference Implementation

2003-12-22 Thread Craig R. McClanahan
Quoting snpe <[EMAIL PROTECTED]>:

> On Monday 22 December 2003 07:04 pm, Craig R. McClanahan wrote:
> > Quoting snpe <[EMAIL PROTECTED]>:
> > > On Monday 22 December 2003 05:56 pm, Craig R. McClanahan wrote:
> > > > Quoting Grassi Fabio <[EMAIL PROTECTED]>:
> > > > > Will Javaserver Faces and in particular Struts-Faces have a
> "editable
> > > > > data grid" component (as I think I've read somewhere)? That would be
> > > > > a very strong motivation to undertake the adoption of the new
> > > > > library.
> > > >
> > > > Yes, it's there ... see the UIData component and the 
> > > > tag. The revised version of the Struts Example app included in the
> > > > struts-faces bundle will use this tag instead of constructing its
> table
> > > > with an interation tag.
> > >
> > > Hello Craig
> > >   Where is new struts-faces ?
> >
> > Still on my hard drive ... at the moment it goes into an endless loop at
> > one particular point in the example app :-(, and I'm not sure whether
> > that's config problems or bugs yet.
> >
> > I'll commit it (and start creating nightly builds based on it) this week.
> >
> 
> is it jakarta-struts module or special struts-faces module in cvs ?
> 

The old code is (and the new code will be) in the jakarta-struts CVS module, in
directory "contrib/struts-faces".

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Example of a non-threadsafe Action?

2003-12-22 Thread Craig R. McClanahan
Quoting David Erickson <[EMAIL PROTECTED]>:

> Hey I have been reading a lot about threading lately from the JLS and
> otherwise.. but my question is what would be an example of a non-threadsafe
> action?  Struts manual said that only one instance of an action exists in
> the JVM.. and when I run an action each thread creates its own versions of
> all the variables within the action correct?

More precisely, you get per-thread *local* variables (i.e. those defined inside
a method).  If you use *instance* variables (those defined in the class, rather
than inside the method, there is only one copy of those variables -- and you
get in trouble if you use those variables to store information that is specific
to a particular request.

> So assuming I'm not accessing
> some outside 'global' variable, everything is inherintly threadsafe right?
> 
> If anyone can give me an example of what 'not' to do that would help
> tremendously.
> thanks,
> David
> 

Consider the LogonAction class in the struts-example app.  Note that the
"username" and "password" variables are defined inside the execute() method, so
they are local variables (and therefore have a copy per thread).

What would happen to your logon processing if you moved those variable
declarations to be outside the method instead of inside?  Then, if you had two
people logging on at the same time, the single copy of the username and
password variables would be at risk for getting scribbled on by the second
user.

The most important rule for thread safety is to use local variables to store
anything that is specific to a particular request (using instance variables to
store read-only copies of things needed by multiple requests, on the other
hand, is fine).

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: R: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta Reference Implementation

2003-12-22 Thread Craig R. McClanahan
Quoting snpe <[EMAIL PROTECTED]>:

> On Monday 22 December 2003 05:56 pm, Craig R. McClanahan wrote:
> > Quoting Grassi Fabio <[EMAIL PROTECTED]>:
> > > Will Javaserver Faces and in particular Struts-Faces have a "editable
> > > data grid" component (as I think I've read somewhere)? That would be a
> > > very strong motivation to undertake the adoption of the new library.
> >
> > Yes, it's there ... see the UIData component and the  tag. 
> > The revised version of the Struts Example app included in the struts-faces
> > bundle will use this tag instead of constructing its table with an
> > interation tag.
> >
> 
> Hello Craig
>   Where is new struts-faces ?
> 

Still on my hard drive ... at the moment it goes into an endless loop at one
particular point in the example app :-(, and I'm not sure whether that's config
problems or bugs yet.

I'll commit it (and start creating nightly builds based on it) this week.

> regards
> Haris Peco
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How find DataSource?

2003-12-22 Thread Craig R. McClanahan
Quoting e-denton Java Programmer <[EMAIL PROTECTED]>:

> I neglected to mention that my servlet container can be passivated on my
> virtual host. So, all objects must be serializable and I can't use static
> variables.
> 

Yet another reason to look it up every time rather than caching it.

Craig

> - Original Message - 
> From: "Vic Cekvenich" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, December 22, 2003 8:31 AM
> Subject: Re: How find DataSource?
> 
> 
> > I put mine in a static block of the base DAO. (static as in once per
> > class, and all DAO's extend my base DAO).
> >
> >
> > .V
> >
> >
> > e-denton Java Programmer wrote:
> >
> > > Merry Christmas,
> > >
> > > Wow, I finally connected to my data source! Now, I want to put the code
> > > somewhere it will be executed only once, and save the DataSource object
> > > where Actions, beans, etc. can get at it. That way, I don't have to
> perform
> > > the lookup all the time.
> > >
> > > Any suggestions on where to put the one time setup code, and where to
> save
> > > the DataSource object reference (in the application?).
> > >
> > > Thanks again,
> > >
> > > Will
> > >
> > > - Original Message - 
> > > From: "Vic Cekvenich" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Saturday, December 20, 2003 12:14 PM
> > > Subject: Re: How find DataSource?
> > >
> > >
> > >
> > >>See sample source code section here:
> > >>
> > >
> > >
>
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
> > >
> > >>Ex:
> > >>Context ctx = new InitialContext();
> > >>   if(ctx == null )
> > >>   throw new Exception("Boom - No Context");
> > >>
> > >>   DataSource ds =
> > >> (DataSource)ctx.lookup(
> > >>"java:comp/env/jdbc/TestDB");
> > >>
> > >>
> > >>Of course what you do with the data source depends on your DAO
> > >>implementataion (iBatis, Hibrenate, etc.)
> > >>
> > >>.V
> > >>
> > >>
> > >>hylepc wrote:
> > >>
> > >>>Hi,
> > >>>
> > >>>From a Data Acess Object (DAO), I need to access a DataSource (like
> > >>>getServletContext().getAttribute (Globals.DATA_SOURCE_KEY)). But, I
> > >
> > > don't
> > >
> > >>>have access to the servlet variable.
> > >>>
> > >>>What is the proper way to get the DataSource from a DAO which is called
> > >
> > > by
> > >
> > >>>an Action but doesn't extend Action?
> > >>>
> > >>>Thanks,
> > >>>
> > >>>Will
> > >>
> > >>
> > >>-
> > >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >>For additional commands, e-mail: [EMAIL PROTECTED]
> > >>
> >
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How find DataSource?

2003-12-22 Thread Craig R. McClanahan
Quoting e-denton Java Programmer <[EMAIL PROTECTED]>:

> Merry Christmas,
> 
> Wow, I finally connected to my data source! Now, I want to put the code
> somewhere it will be executed only once, and save the DataSource object
> where Actions, beans, etc. can get at it. That way, I don't have to perform
> the lookup all the time.
> 

That turns out not to be the recommended pattern, for at least two reasons:

* If your app server supports the ability to dynamically
  reconfigure DataSource objects while your app is running,
  the object retrieved via JNDI might change each time.

* If you retrieve it once and then put it someplace (such as
  in a servlet context attribute) then any code that wants to
  retrieve it will need a reference to the ServletContext object
  (and therefore be dependent on the servlet API).



> Any suggestions on where to put the one time setup code, and where to save
> the DataSource object reference (in the application?).
> 

Consider setting up a utility class with a public static method called
getDataSource() that actually does the lookup every time.  Then you can call it
like:

  DataSource ds = MyUtils.getDataSource("jdbc/TestDB");

or, even go a step farther and have it return a connection for you ... that way
you're hiding how the connection pooling is being done as well, and just
operating at the SQL level.

> Thanks again,
> 
> Will
> 

Craig


> - Original Message - 
> From: "Vic Cekvenich" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, December 20, 2003 12:14 PM
> Subject: Re: How find DataSource?
> 
> 
> > See sample source code section here:
> >
>
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
> >
> > Ex:
> > Context ctx = new InitialContext();
> >if(ctx == null )
> >throw new Exception("Boom - No Context");
> >
> >DataSource ds =
> >  (DataSource)ctx.lookup(
> > "java:comp/env/jdbc/TestDB");
> >
> >
> > Of course what you do with the data source depends on your DAO
> > implementataion (iBatis, Hibrenate, etc.)
> >
> > .V
> >
> >
> > hylepc wrote:
> > > Hi,
> > >
> > > From a Data Acess Object (DAO), I need to access a DataSource (like
> > > getServletContext().getAttribute (Globals.DATA_SOURCE_KEY)). But, I
> don't
> > > have access to the servlet variable.
> > >
> > > What is the proper way to get the DataSource from a DAO which is called
> by
> > > an Action but doesn't extend Action?
> > >
> > > Thanks,
> > >
> > > Will
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: R: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta Reference Implementation

2003-12-22 Thread Craig R. McClanahan
Quoting Grassi Fabio <[EMAIL PROTECTED]>:

> Will Javaserver Faces and in particular Struts-Faces have a "editable
> data grid" component (as I think I've read somewhere)? That would be a
> very strong motivation to undertake the adoption of the new library.
> 

Yes, it's there ... see the UIData component and the  tag.  The
revised version of the Struts Example app included in the struts-faces bundle
will use this tag instead of constructing its table with an interation tag.

Craig

> Thanks in advance, Fabio.
> 
> 
> 
> > -Messaggio originale-
> > Da: Craig R. McClanahan [mailto:[EMAIL PROTECTED] 
> > Inviato: sabato 20 dicembre 2003 05:17
> > A: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Oggetto: JavaServer Faces 1.0 -- Proposed Final Draft Spec 
> > and Beta Reference Implementation
> > 
> > 
> > 
> > 
> > I'm pleased to announce that the Proposed Final Draft version 
> > of the JavaServer
> > Faces 1.0 Specification, and a corresponding Beta release of 
> > the Reference
> > Implementation, is now available at:
> > 
>   http://java.sun.com/j2ee/javaserverfaces/download.html
> 
> Please send any feedback and comments strictly about JavaServer Faces to
> <[EMAIL PROTECTED]>.
> 
> I'm also finishing up an update to the Struts-Faces Integration Library,
> and
> will be making it available (via nightly builds) very soon.  Feel free
> to ask
> any questions about how to use Struts and JavaServer Faces here on the
> STRUTS-USER list.
> 
> Craig McClanahan
> 
> Ai sensi della Legge 675/96, si precisa che le informazioni contenute in
> questo messaggio sono riservate ed a uso esclusivo del destinatario. Qualora
> il messaggio in parola Le fosse pervenuto per errore, la preghiamo di
> eliminarlo senza copiarlo e di non inoltrarlo a terzi, dandocene gentilmente
> comunicazione. Grazie.This message, for the law 675/96 may contain
> confidential and/or privileged information. If you are not the addressee or
> authorized to receive this for the addressee, you must not use, copy,
> disclose or take any action based on this message or any information herein.
> If you have received this message in error, please advise the sender
> immediately by reply e-mail and delete this message. Thank you for your
> cooperation.




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta Reference Implementation

2003-12-20 Thread Craig R. McClanahan
Quoting Nadeem Bitar <[EMAIL PROTECTED]>:

> Graig, 
> regarding the struts-faces integration library, would it support tiles?
> 

That's the part I'm not quite done wth, but it's definitely the intent.

Craig


> On 金, 2003-12-19 at 20:16, Craig R. McClanahan wrote:
> > I'm pleased to announce that the Proposed Final Draft version of the
> JavaServer
> > Faces 1.0 Specification, and a corresponding Beta release of the Reference
> > Implementation, is now available at:
> > 
> >   http://java.sun.com/j2ee/javaserverfaces/download.html
> > 
> > Please send any feedback and comments strictly about JavaServer Faces to
> > <[EMAIL PROTECTED]>.
> > 
> > I'm also finishing up an update to the Struts-Faces Integration Library,
> and
> > will be making it available (via nightly builds) very soon.  Feel free to
> ask
> > any questions about how to use Struts and JavaServer Faces here on the
> > STRUTS-USER list.
> > 
> > Craig McClanahan
> > 
> > 
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



JavaServer Faces 1.0 -- Proposed Final Draft Spec and Beta Reference Implementation

2003-12-19 Thread Craig R. McClanahan


I'm pleased to announce that the Proposed Final Draft version of the JavaServer
Faces 1.0 Specification, and a corresponding Beta release of the Reference
Implementation, is now available at:

  http://java.sun.com/j2ee/javaserverfaces/download.html

Please send any feedback and comments strictly about JavaServer Faces to
<[EMAIL PROTECTED]>.

I'm also finishing up an update to the Struts-Faces Integration Library, and
will be making it available (via nightly builds) very soon.  Feel free to ask
any questions about how to use Struts and JavaServer Faces here on the
STRUTS-USER list.

Craig McClanahan


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] HTML Select box

2003-12-19 Thread Craig R. McClanahan
Quoting Brice Ruth <[EMAIL PROTECTED]>:

>  From a GUI perspective, how would you select multiple things in a 
> drop-down? I can't actually recall ever seeing this type of widget 
> anywhere (irrespective of HTML).
> 

In HTML, this is triggered by the "multiple" attribute on the  element. 
If you're using  tag, must add multiple="true".

In a browser, it's the usual technique for multiple selections -- shift-click
selects everything between the previous point and the current point, while
control-click adds the individual item you're currently pointing at.

> Could you send an example?
> 

Craig


> Jerry Jalenak wrote:
> 
> >Hi All,
> >
> >Can't seem to find a way to do this, even though I've seen it done (I
> >think).  What I need is a HTML select box where the size parameter=1 (so I
> >get a true drop-down, not a scrolling box) AND the ability to select
> >multiple options within the select box.  Right now if I set the multiple
> >parameter I get a scrolling box.  I'm using an optionsCollection tag to
> >generate my option list (not that I think it has anything to do with my
> >problem  8-)  I suspect there is a JavaScript solution out there, but I
> >can't seem to google it.  Does anyone have any ideas?
> >
> >TIA!
> >
> >Jerry Jalenak
> >Development Manager, Web Publishing
> >LabOne, Inc.
> >10101 Renner Blvd.
> >Lenexa, KS  66219
> >(913) 577-1496
> >
> >[EMAIL PROTECTED]
> >
> >
> >This transmission (and any information attached to it) may be confidential
> and
> >is intended solely for the use of the individual or entity to which it is
> >addressed. If you are not the intended recipient or the person responsible
> for
> >delivering the transmission to the intended recipient, be advised that you
> >have received this transmission in error and that any use, dissemination,
> >forwarding, printing, or copying of this information is strictly
> prohibited.
> >If you have received this transmission in error, please immediately notify
> >LabOne at the following email address: [EMAIL PROTECTED]
> >
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >  
> >
> 
> -- 
> Brice D. Ruth
> Sr. IT Analyst
> Fiskars Brands, Inc.
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How multiple servlet-mappings affect computed action path?

2003-12-19 Thread Craig R. McClanahan
Quoting Daniel Rabe <[EMAIL PROTECTED]>:

> I started out with a simple struts webapp, so my web.xml maps *.do to
> myServlet. Then I recognized a need to have a set of requests dispatched to
> my servlet based on the first part of path_info, so I added a new mapping
> from /special/* to myServlet. (These requests will NOT have ".do" at the
> end.)
> 
> Now when I have a JSP with , the action that
> appears in the generated HTML is /myServlet/special/myFormSave.do instead of
> just /myServlet/myFormSave. Why is this? How can I fix it?
> 
> Thanks,
> Daniel Rabe
> 
> 


Struts does not support having the Action servlet mapped both ways ... you need
to choose one or the other.  Note that extension mappings still work even if
there are "directory levels" on the front of the URL.

If you really want URLs that are path mapped, tere are messages in the
STRUTS-USER mailing list archives about using filters to transform the incoming
URL for you (requires Servlet 2.3 or later).

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [SPAM] Your Support Question

2003-12-19 Thread Craig R. McClanahan
Quoting Joe Hertz <[EMAIL PROTECTED]>:

> Yeah, I get it too. 
> 
> Silly me, I just assumed that it was a legitimate company, and some
> (probably their only one, IMHO) employee sub'd to the struts list and
> this was some sort of auto-responder for him. I mainly thought this
> because it didn't look like Spam. Only in the last WEEK has started to
> solicit "business".
> 
> I've asked them to turn it off at least twice myself. The solicitation
> got added after that. The attitude appears to be quite clear.
> 

It's fixed now, so STRUTS-USER posters should no longer get spammed.

> -Joe

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Sharing struts taglibs in Tomcat

2003-12-15 Thread Craig R. McClanahan
Quoting Ed Dowgiallo <[EMAIL PROTECTED]>:

> I am doing a lot of struts development and would like to place the struts jar
> files in the $TOMCAT_HOME/shared/lib directory instead of WEB-INF/lib for
> each individual war file.
> 
> What values for  in web.xml are likely to make this work?  Is there
> another way to accomplish the same effect?
> 
> Struts 1.1
> Tomcat 4.1.29
> 
> Thank you,
> Ed


http://jakarta.apache.org/struts/userGuide/configuration.html#config_add

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Mailing large number of recipients

2003-12-06 Thread Craig R. McClanahan
Quoting Shyam A <[EMAIL PROTECTED]>:

> Kirk,
> 
> Thanks a lot for your suggestions. I will look into
> JMS.
> In my current approach, the process of sending the
> mail is time consuming.I'm concerned that sending an
> email to 1000's of recipients from my application
> (using JMS, Thread etc) would clog my application
> server (OC4J) and slow down its operation, which is
> why I was wondering if it could be done at the
> backend-Oracle 9i.
> 

Would it not be simpler to set up a mailing list application on your mail
server, so you only have to send the message to a single recipient address
(pretty much the way the struts-user mailing list works)?  This would also
relieve you of the burden of having to change your application every time the
list of recipients changs.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: struts-faces Roadmap

2003-11-25 Thread Craig R. McClanahan
Quoting Nadeem Bitar <[EMAIL PROTECTED]>:

> Is there a roadmap for the struts and jsf integration library? I am
> particularly interested in an update that would support tiles. I already
> tried the modifications suggested in the developerworks article
> (http://www-106.ibm.com/developerworks/library/j-integrate)
> with partial success, but I would prefer that it was supported directly
> in struts-faces.
> thanks in advance,
> nadeem
> 

The plan is definitely to keep struts-faces up to date with the upcoming beta
and final releases of JavaServer Faces.  Ensuring that Tiles support works is
very high on my agenda; it's a matter of having sufficient time to integrate
and test the solution.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: problem - urgent..help!!

2003-11-25 Thread Craig R. McClanahan
Quoting "Daniel A. Torrey" <[EMAIL PROTECTED]>:

> I don't think that java.net.URL is capable of setting up an SSL connection.
> 
> -daniel
> 

Actually, it is possible if you have JSSE available (or you're running JDK 1.4
or later, which includes JSSE).

http://java.sun.com/products/jsse/

> Daniel A. Torrey
> daniel at datorrey dot net
> 

Craig


> 
> 
> Quoting "Khalid K." <[EMAIL PROTECTED]>:
> 
> > platform:  AIX/Websphere
> > Struts V:  1.0.2
> > 
> > Problem:  
> >   
> > 
> > the above code works fine in windows - none SSL environment.
> > When we migrate the code to AIX/Websphere that has SSL installed..
> > hence..https://blahblah... The above code throws:
> > java.net.MalformedURLException: unknown protocol: https
> > 
> > Last time I checked https is a valid protocol...HELP! THANKS!
> > 
> > Thanks in advance!!! (cant use jsp:include ...custom wrappers etc...)
> > 
> > 
> > WebGroup  X Servlet Error: Cannot create include URL:
> > java.net.MalformedURLException: unknown protocol: https:
> > javax.servlet.jsp.JspException: Cannot create include URL:
> > java.net.MalformedURLException: unknown protocol: https
> > at
> > org.apache.struts.taglib.bean.IncludeTag.doStartTag(IncludeTag.java)
> > at noticeofchange._notice_5F_of_5F_change_jsp_5._jspService
> > (_notice_5F_of_5F_change_jsp_5.java:241)
> > at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java
> > (Compiled Code))
> > 
> > 
> > 
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Server manged vs. struts managed db pools

2003-11-24 Thread Craig R. McClanahan
Quoting Edgar P Dollin <[EMAIL PROTECTED]>:

> I like struts managed db pools, however, the struts developers aren't too
> happy about the quality and the dependency on the commons-pooling library
> and are attempting to phase it out.
> 

The existing connection pool in struts-legacy.jar (and the one in
commons-dbcp.jar nowdays) works fine.  However, there are several important
pros for using container managed connection pools:

* A connection pool implementation provided by your app server
  is likely to be optimized for better performance on that particular
  app server than a generic pool included with the app.

* A connection pool implementation provided by your app server
  is likely to be supported by the graphical admin tools of that
  app server, versus having to be hand configured in struts-config.xml.

* On some app servers, you can dynamically tweak the characteristics
  of the connection pool (such as how many active connections are allowed)
  without restarting the app.  That's not the case for a pool included
  inside the app, where you have to go tweak struts-config.xml and restart.

* A connection pool provided by your app server vendor is accessible
  (via JNDI) *anywhere* in your application, versus having to be passed
  in as a parameter to any method that needs it (or making your business
  logic dependent on the servlet API in order to access application scope
  attributes).

* In environments where you have two or three different deployment
  scenarios (say, "development", "test", and "production") you can
  deploy exactly the same WAR file in all three places, yet have each
  of them talk to the correct database simply by administering the
  server.  No tweaking of the struts-config.xml file to reflect which
  environment you are deploying to.

The only reason Struts ever included a connection pool in the first place is
that most standalone servlet containers at that time didn't support JNDI-based
pools.  Now, that is no longer an issue, and I would always recommend using the
container's facilities for that purpose.

> Edgar
> 

Craig


> > -Original Message-
> > From: Nathan Maves [mailto:[EMAIL PROTECTED] 
> > Sent: Tuesday, November 18, 2003 2:52 PM
> > To: Struts Users Mailing List
> > Subject: Server manged vs. struts managed db pools
> > 
> > 
> > Are there any pro/con 's for either?
> > 
> > Nathan
> > 
> > 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: struts and PHP

2003-11-24 Thread Craig R. McClanahan
Quoting Christian Bollmeyer <[EMAIL PROTECTED]>:

> Am Montag, 17. November 2003 22:48 schrieb Daniel Blumenthal:
> 
> Hi,
> 
> > i've been looking into adding blogging functionality to my website
> > (which uses struts), and one which was suggested was pmachine
> > (http://www.pmachine.com/index.php). however, this uses php, and this
> > raised the question of how/if it was possible to use php with struts.
> > (obviously, i can just specify a php page instead of a jsp, but how
> > do i get dynamic data without relying on the jsp tags?)
> 
> As soon as you leave the Java world, the only means of passing
> dynamic content is the 'traditional' way, i.e. parameters. You lose
> everything from page to application scopes and won't be able
> to use attributes (Objects) in particular, as those reside inside
> the VM's memory and thus are inaccessible from PHP.

Alas, this is pretty much the case today.  However, there is a JSR in progress
that is excplicitly designed to define a standard way that scripting languages
and Java can interact (and share access to Java objects, and the HttpSession
instance, along the way).  Keep an eye out for progress on:

  http://jcp.org/en/jsr/detail?id=223

Note that the Zend folks are actively involved in this effort, so we can expect
that support for PHP in particular should be pretty well planned.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: PDF File Display in JSP-Struts

2003-11-12 Thread Craig R. McClanahan
Quoting Christian Bollmeyer <[EMAIL PROTECTED]>:

> Am Mittwoch, 12. November 2003 21:31 schrieb Craig R. McClanahan:
> > Quoting Larry Meadors <[EMAIL PROTECTED]>:
> > > Why would you ever do this? This looks like a complete and total
> > > kludge.
> > >
> > > If you are sending back binary data (application/pdf), just do it
> > > from the action class using the response.getOutputStream() and
> > > return null from the execute method.
> > >
> > > Advantages:
> > >  - you already have everything you need right there
> > >  - you eliminate the entry in struts-config
> > >  - you eliminate a useless jsp
> > >  - you can specify any content type (not just one per jsp)
> > >  - you get better exception handling
> > >  - the list could go on and on...
> >
> > There's actually a much more fundamental reason than all of the above
> > (which are true nonetheless) -- JSP pages are not allowed to create
> > binary output.  They never call response.getOutputStream().
> 
> That's how it's meant to be, and JSPs themselves don't, but you
> can always shed in a scriptlet to make them behave otherwise.

You might get lucky on some containers, but you can be assured that writing
binary output from a scriptlet is not guaranteed to be portable.  Indeed,
you're more likely to cause an IllegalStateException, because the servlet
container won't let you call getWriter() and getOutputStream() on the same
response.

>  I've seen people doing just ridiculous things with JSPs, some
> of them routinely putting a <% at the top and a %> at the end,
> and then went on happily putting everything imaginable in-bet-
> ween, usually with lengthy <%@ page import="[xy]" %> state-
> ments on top. Won't support Mark Galbreath on this matter,
> so if there may be a grain of truth in his direction, I'm still
> just telling from my personal experiences, limited to a
> single case, thankfully. But never underestimate human
> ingenuity ;-)
> 

s/ingenuity/foolishness/

:-)

I remember in the pre-Struts days of someone on the JSP Interest mailing list
talking about the fact that they had a 5000 line JSP page that implemented the
entire app (complete with creating different forms and processing the results)
-- all in a single page.  And he was *proud* of it!


> > > Larry
> >
> > Craig
> 
> -- Chris.
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: PDF File Display in JSP-Struts

2003-11-12 Thread Craig R. McClanahan
Quoting Larry Meadors <[EMAIL PROTECTED]>:

> Why would you ever do this? This looks like a complete and total kludge.
> 
> If you are sending back binary data (application/pdf), just do it from the
> action class using the response.getOutputStream() and return null from the
> execute method.
> 
> Advantages: 
>  - you already have everything you need right there
>  - you eliminate the entry in struts-config
>  - you eliminate a useless jsp
>  - you can specify any content type (not just one per jsp)
>  - you get better exception handling
>  - the list could go on and on...
> 

There's actually a much more fundamental reason than all of the above (which are
true nonetheless) -- JSP pages are not allowed to create binary output.  They
never call response.getOutputStream().

> Larry
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: tiles and getRequestURI

2003-11-11 Thread Craig R. McClanahan
Quoting James Norman <[EMAIL PROTECTED]>:

> I'm in the process of porting a web application from the
> Jetspeed/Turbine framework over to struts and I ran into a problem
> someone may be able to help me with.
> 
> When I have a Jsp that is included by a tile, the
> httpServletRequest.getRequestURI() returns the location of the Jsp that
> the tiles included, not the resource that the browser requested.  As far
> as I can tell, it is the Tiles Controller that is changing this from the
> original set by the container.  This is causing some problems in the
> application I have because the requestURI becomes something like
> /WEB-INF/templates/body.jsp, which isn't terribly useful.  I have found
> a few emails regarding this in the archives, but no solutions.  Is there
> a configuration which will tell the controller not to mess with the
> requestURI?  Any insight would be appreciated.
> 

You will see this sort of behavior in any servlet-based application that uses
RequestDispatcher.incude() -- as Tiles does -- to assemble the various
subcomponents of the page together.  The servlet API requires that the request
URI (as well as the other path components like the servlet path) be adjusted in
such scenarios to point at the included resource.

The request URI of the original request is still available to the included
resource, however -- it's stored by the container in a request attribute under
the key "javax.servlet.include.request_uri", along with the other path
components under similarly named keys.  See Section 8.3.1 of the Servlet Spec
for details.

> Thanks,
> James Norman
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ResultSetDynaClass etc...

2003-11-11 Thread Craig R. McClanahan
Quoting "Sumit S." <[EMAIL PROTECTED]>:

> The ResultSetDynaClass & ResultSetDynaBeans are a powerful way of
> encapsulating ResultSets in DynaClasses. However, when we need to transfer
> the data from such a DynaClass to a ValueObject (say a structs ActionForm),
> the PropertyUtils.copyProperties looks for a property name match.
> 
> So now my ActionForm attributes get tied to the DB Column namesand if at
> a later point in time, the column names are changed, it means a change in
> code.
> 
> One option is to store the mapping information in a simple configuration file
> and override the copyProperties to take this mapping info as an input
> parameter as well...
> 
> something like
> 
> copyProperties (Object dest, Object src, Map map)
> {
> for each property in src
> read the value from source.
> get the corresponding property name in dest from the map
> set the property value in the dest
> }
> 
> I have written a small class to do the above
> Is there a more elegant way of doing it.The config might be XML or Text
> based which can be converted into Map objects & cached.
> 

The method you suggest for disconnecting your DynaBeans from column names works,
but you can accomplish the same thing in SQL directly as well:

  select account_id as account, customer_name as name, street_address as
address
from customers where (credit_limit > 500.00);

creates three "properties" in the result set named "account", "name", and
"address" that are totally independent of the names used in the underlying
database schema.  To me, it seems easier to let the database queries maintain
the naming independence than to do it separately in code.

> Thanks
> Sumit
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts across WARs

2003-11-10 Thread Craig R. McClanahan
Quoting Brice Ruth <[EMAIL PROTECTED]>:

> I don't believe sharing Tiles across WARs is possible, since the Tiles 
> plug-in needs the Tiles 'context' which would be specific to the Tiles 
> plug-in that is processing a particular request, if I'm not mistaken ... 
> since each WAR runs its own Tiles plug-in, I don't believe any Tiles 
> related data can be shared ...
> 

It's not just Tiles resources you cannot share -- basically, you cannot share
*anything* across webapps unless you leverage container-specific facilities
(like the common/lib or shared/lib directory in Tomcat).  The fundamental issue
is that each webapp gets loaded by it's own class loader, which cannot see any
classes or resources from any other webapp.

A common strategy is to manage the shared resource files in a single source code
repository (so you only have to do changes once), and then arrange that the
application assemby portion of your build process pulls the required resources
into each WAR that needs them.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts-chain

2003-11-08 Thread Craig R. McClanahan
Quoting BaTien Duong <[EMAIL PROTECTED]>:

> Thanks. I hacked it and got the job done.
> 
> It is a great job Craig. Your vision proves to be on the target again.
> 
> By the way, file upload is a very important aspect of Struts 
> applications. I will look closely into it. But is there any serious 
> reason while file-upload is *NOT SUPPORTED YET* in the struts-chain?
> 

It's only NOT SUPPORTED YET because nobody has done the work to support it :-). 
Feel free to take a crack at this, but it's probably going to be somewhat more
involved than some of the other functionality, to replicate or replace the way
that the standard FileUpload functionality wraps the servlet request.

If it were up to me, I'd just implement file upload as a Filter instead of
inside the framework, but that would mean requiring a Servlet 2.3 platform.


> On behalf of many developers, me included, thanks for your great effort. :-)
> 

You're welcome ... its going to be fun to see the various ways commons-chain
gets employed.

> BaTien
> DBGROUPS
> 

Craig


> Craig R. McClanahan wrote:
> 
> >Quoting BaTien Duong <[EMAIL PROTECTED]>:
> >
> >  
> >
> >>Howdy:
> >>
> >>I am trying to get Struts-chain up and running. I follow the instruction 
> >>of struts-chain in the cvs to build from the source:
> >>
> >>export ANT_HOME=.../ant-1.6beta2
> >>export JAVA_HOME=.../j2sdk1.4.2_02
> >>export TOMCAT_HOME=.../tomcat-5.0.14
> >>
> >>The build.properties is copied from the build.properties.sample
> >>   servlet.home=.../common/lib
> >>   struts.home=.../jakarta-struts-bin
> >>   chain.home=.../cvs/jakarta-commons-sandbox/chain
> >>
> >>export 
> >>
> >>
> >>
>
>PATH=${PATH}:${JAVA_HOME}/bin:${ANT_HOME}/bin:${TOMCAT_HOME}/common/lib/servlet-api.jar:${TOMCAT_HOME}/server/lib/catalina-ant.jar
> >  
> >
> >>execute the following command at the struts-chain directory
> >>[-]$ ant clean dist
> >>
> >>I got the error:
> >>   /build.xml:54: taskdef class org.apache.catalina.ant.DeployTask could 
> >>not be found
> >>
> >>Please feed me the latest instruction to create struts-chain.war
> >>
> >>
> >>
> >
> >Copy the "catalina-ant.jar" file from your Tomcat install's server/lib
> directory
> > into the "lib" directory of Ant.  This causes the Tomcat integration
> commands
> >to be recognized.
> >
> >  
> >
> >>Thanks
> >>BaTien
> >>DBGROUPS
> >>
> >>
> >
> >Craig
> >
> >
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >.
> >
> >  
> >
> 
> 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts-chain

2003-11-08 Thread Craig R. McClanahan
Quoting Vic Cekvenich <[EMAIL PROTECTED]>:

> 
> 
> BaTien Duong wrote:
> 
> 
>   i am able to have struts-chain example (the old
> > struts-example with struts-chain built from cvs) up and running using 
> > j2sdk1.4.2_02 and tomcat 5.0.14. 
> 
> 
> Where did you find an example of using a Struts chain?
> 
> .V
> 

Download the jakarta-struts nightly source distro (or check it out from
anonymous CVS).  Then, start Tomcat and execute:

  cd contrib/struts-chain
  ant install

This builds a variation on the standard struts-example webapp that uses the
chain-based replacement for the standard RequestProcessor.

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Re[4]: EL Expression in html:hidden tag

2003-11-08 Thread Craig R. McClanahan
Quoting Arne Brutschy <[EMAIL PROTECTED]>:

> Hello,
> 
> Monday, November 3, 2003, 7:20:31 PM, you wrote:
> KS> I'm jumping in late on this thread, but why bother using Struts-EL at all
> under
> KS> JSP 2.0? The original (RT) tags should be magically EL-aware as long as
> the app
> KS> uses a Servlet 2.4 format web.xml, right?
> 
> Oh, really? I didn't know that. So I can work with the normal struts
> lib? I just need to declare a 2.4 web-app?
> 

And run in a Servlet 2.4 / JSP 2.0 container of course ;-)

Not only will EL expressions work for attributes in any tag (as long as the
attribute accepts runtime expressions), it will also work in template text. 
Consider a snippet like this to display a table of stuff from a list of
customer beans in a scoped variable named "customers":

  

  Account Id
  Customer Name
  Total Sales


  
${customer.accountId}
${customer.name}
${customer.totalSales}
  

  

JSP 2.0 has lots of other cool things to, including the ability to point at a
chunk of JSP code and treat it just like a tag, without having to write
anything in Java.

> Thanks,
> Arne
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re:Struts-chain

2003-11-08 Thread Craig R. McClanahan
Quoting BaTien Duong <[EMAIL PROTECTED]>:

> Howdy:
> 
> I am trying to get Struts-chain up and running. I follow the instruction 
> of struts-chain in the cvs to build from the source:
> 
> export ANT_HOME=.../ant-1.6beta2
> export JAVA_HOME=.../j2sdk1.4.2_02
> export TOMCAT_HOME=.../tomcat-5.0.14
> 
> The build.properties is copied from the build.properties.sample
>servlet.home=.../common/lib
>struts.home=.../jakarta-struts-bin
>chain.home=.../cvs/jakarta-commons-sandbox/chain
> 
> export 
>
PATH=${PATH}:${JAVA_HOME}/bin:${ANT_HOME}/bin:${TOMCAT_HOME}/common/lib/servlet-api.jar:${TOMCAT_HOME}/server/lib/catalina-ant.jar
> 
> execute the following command at the struts-chain directory
> [-]$ ant clean dist
> 
> I got the error:
>/build.xml:54: taskdef class org.apache.catalina.ant.DeployTask could 
> not be found
> 
> Please feed me the latest instruction to create struts-chain.war
> 

Copy the "catalina-ant.jar" file from your Tomcat install's server/lib directory
 into the "lib" directory of Ant.  This causes the Tomcat integration commands
to be recognized.

> Thanks
> BaTien
> DBGROUPS

Craig



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Which version of Commons Digester released with Struts 1.1

2003-11-08 Thread Craig R. McClanahan
Quoting Philip Mark Donaghy <[EMAIL PROTECTED]>:

> I would like to debug a problem that I have with
> Digester. The error is :
> 
> java.lang.NoSuchMethodException: No such accessible
> method: addFormBeanConfig() on object:
> java.lang.String
> 

Well, the error message says that there's no addFormBeanConfig() method on the
java.lang.String class :-).

More seriously, there's no way to know what's really going on without seeing the
kinds of Digester rules you are configuring, and what kind of document you are
trying to parse.

> How can I get the version number that is distributed
> with Struts 1.1.
> 

The Struts release notes describe the included versions of all the commons
libraries.  In addition, the version information about JAR files in general
should be in a META-INF/MANIFEST.MF file in the jar (and it is there for all
the libraries that Struts includes).

> Phil
> 

Craig


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: attribut vs name in action definition

2003-10-30 Thread Craig R. McClanahan
Steven Woody wrote:

Hi,

In the MailReader examples's struts-config.xml, I noticed there are two different config mthod to associate a ActionForm to a Action.  One use attribute,

   
others use  'name',

   
What is the difference?

And, Struts-1.1 come with a JavaDoc for classes, but I did not find a reference manual for configuration files.  Is there anyone?

 

Thanks for looking for the docs -- it always makes me feel better when 
people at least *try* to look up the answers for themselves :-).  The 
"reference manual" for the configuration files is the comments in the 
DTD itself.  Open "lib/struts-config_1_1.dtd" in your favorite text 
editor, and you'll see the information about all the available elements 
and attributes.

That includes the fact that form beans are normally stored as a request 
or session scope attribute under a key equal to the form name.  If you 
want to reuse a particular  element, but store the actual form 
bean instance under different request scope or session scope keys, 
that's what the "attribute" attribute is for.

Regards.
--
Steven Woody
[EMAIL PROTECTED]
 

Craig



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Design decision for Globals class

2003-10-30 Thread Craig R. McClanahan
Justin Mahoney wrote:

Hi guys,
Thanks for your replies.
Can you give examples of usage patterns that would dictate that it is ok to
move constants away from their owning classes?
I also think the type safe enum pattern is a great idea, but I do not see
this being used a lot in practice (though I think it should be).
Justin
 

Constants are not always "owned" or strongly related to any particular 
class -- in those scenarios, you definitely want to move to a common one 
(like we did with Globals in Struts 1.1).  It can also lead to cleaner 
imports if you only have to import one class to get the constant 
declarations.

A related hack I've seen used on occasion is to define the global 
constants in an interface, rather than a class.  Then, your logic class 
can say "implements Globals" and reference the constant names directly 
(without having to prefix them with the class name, as you do to 
reference static constants in other classes).

Typesafe enums make sense when the underlying data really is an 
enumeration of values that represents the total set of valid inputs to a 
method.  This is true, for example, when the constants are the integer 
subscripts into a fixed size array, and you want to avoid the 
possibility of IndexOutOfBound exceptions.  (On the other hand, it makes 
iterating through the values harder.)  I don't find them of much use 
when the constants are Strings, because in most of those scenarios the 
number of legal values is usually not limited -- the constants are just 
well-known identifiers rather than being the only valid values.  For 
example, it wouldn't make sense to define a typesafe enum class for 
request attribute keys.

Craig

-Original Message-
From: John Cavacas [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 29, 2003 7:43 PM
To: Struts Users Mailing List
Subject: Re: Design decision for Globals class
I agree with David. Constants should be defined where they are relevant. 
But once you start using them in other places, then refactor them out to a 
common Constants class. The Type Safe Enum pattern might also be something 
worth looking at depending on your use of such constants.

John

At 04:15 PM 29/10/2003 -0800, you wrote:
 

In general, constants should be defined in the class they're relevant in.
The Struts Globals constants used to be defined in Action; however,
they're used in many places other than Action so it made sense to move
them to the new Globals class.
David

--- Justin Mahoney <[EMAIL PROTECTED]> wrote:
   

Hi,
A colleague of mine and I are discussing the relative merits of having
something like a Globals class.
I argue that it removes the constants from their proper association with
a
parent/owning class, ignoring the concept of object orientation and
losing a
self-documenting aspect regarding its relationship in the class
hierarchy.
By making the constants global they inherently lose scope, type
association,
and encapsulation. Another drawback is that you now have to flip between
two
JavaDocs pages when looking at a class and its constants.
My friend argues that it's easier to reference a Globals class when
programming since all constant Strings useful in the architecture are
collected within, and therefore this is reason enough to have a Globals
class (works great obviously with IDE auto-complete).
If anyone has the time or inclination to comment, what were the design
decisions that led to the Struts Globals class?
Thanks,
Justin
 

__
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: declaring action mappings at runtime

2003-10-30 Thread Craig R. McClanahan
Ahmet ISIK wrote:

I'm doing it in a plugin.
My purpose is to develop generic CRUD operations, views and forms for 
any model object that is persisted using Hibernate. For this, I 
introspect Hibernate config and provide form fields according to 
underlying object's properties.
I'm declaring actionmappings at runtime because I'm asking Hibernate 
for a list of entities that are declared.

Modifying the configuration information in a PlugIn is specifically 
allowed, for precisely this kind of purpose.  It is safe, because 
plugins are called from the init() method of ActionServlet, and must all 
complete successfully before the first request is processed.

Struts freezes the configuration information *after* the plugins have 
been initialized; from that point on, you'll get IllegalStateExceptions 
if you try to modify existing XxxConfig beans in any way.

Craig


Martin Cooper wrote:

"Ahmet ISIK" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
thanks Martin,
I have found a solution. I have acquired module config by
Globals.MODULE_KEY key from app context. Then I added programmatically
configured ActionMappings to module config object. after that it is
possible to use those action mappings. Is this a bad practice?


Where are you doing this? (And why?)

If you're doing it in a plug-in, then I believe it will work, but I 
don't
see how that would be any more "dynamic" than adding them to your Struts
config file. (Also in that case, you are already passed the module 
config,
so you wouldn't need to look it up, as you mentioned you are doing.)

If you're doing it outside of a plug-in, then I'm puzzled. Once 
Struts loads
the config, it freezes it and throws IllegalStateException if you 
attempt to
modify it.

--
Martin Cooper


Martin Cooper wrote:

"Ahmet ISIK" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

Hi,
Is it possible to declare struts action mappings at runtime, and how?


No, it's not possible. The config is read in at application startup 
and

is

then frozen. (The reason it's done this way is so that access to the

config

does not need to be synchronised once the app is up and running, thus
leading to much improved overall performance.)
--
Martin Cooper



Thanks in advance

--
Ahmet ISIK
Ideal Teknoloji Bilisim Çözümleri A.S.- Iliskisel Is Kanali
Yazilim Muhendisi
http://www.idealteknoloji.com






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
Ahmet ISIK
Ideal Teknoloji Bilisim Çözümleri A.S.- Iliskisel Is Kanali
Yazilim Muhendisi
[EMAIL PROTECTED]
http://www.idealteknoloji.com






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: specifying image source as jpg stream

2003-10-27 Thread Craig R. McClanahan
Max Cooper wrote:

You may want to write a separate servlet to serve the image data. That
allows you to implement getLastModified() and allow proper browser-caching
support, which can significantly increase the speed of your pages if the
user is likely to view the images more than once. We did this with an Action
first and since we had caching turned off, it reloaded the images every
time. Switching to a separate servlet where we implemented getLastModified()
was perceptably faster.
Perhaps Struts should allow Action-implementers to implement some kind of
getLastModified() method for this reason. Or at least to turn caching on and
off at the Action (or action-mapping) level. getLastModified() is really
useful if you have the image data (or document data, etc.) stored in a db.
 

Controlling this stuff at the per-Action level is a nice idea.  If 
you're using an Action to create dynamic output already (such as when 
you directly stream the binary output and then return null), it's quite 
easy to do today -- your Action will be able to see the 
"If-Modified-Since" header that the browser sends, and then can decide 
to return a status 304 (NOT MODIFIED) if your current database stuff is 
not more recent.

Something along the lines of this in your Action.execute() method should 
do the trick:

   // When was our database data last modified?
   long dataModifiedDate = ... timestamp when database last modified ...
   // Have we sent to this user previously?
   long modifiedSince = request.getDateHeader("If-Modified-Since");
   if (modifiedSince > -1) { // i.e. it was actually specified
   if (dataModifiedDate <= modifiedSince) {
  response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
   return (null);
   }
   }
   // Set the timestamp so the browser can send back If-Modified-Since
   response.setDateHeader("Date", dataModifiedDate);
   // Now write the actual content type and data
   response.setContentType("mage/jpg");
   ServletOutputStream stream = response.getOutputStream();
   ... write out the bytes ...
   // Return null to tell Struts the response is complete
   return (null);
-Max

 

Craig



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: More than one condition using struts logic tags???

2003-10-27 Thread Craig R. McClanahan
[EMAIL PROTECTED] wrote:

Hello,

I have a little query ->

How can I check for more that one condition using struts logic tags? like 

if (A & B & C) {
do something.
}
how do I achieve the same using struts logic tags?
 

You can do an "and" test by nesting  tags inside each other.  
There's no convenient way to do an "or" test however; that's where the 
expression language in JSTL and JSP 2.0 comes in very handy (if you're 
running on a recent enough servlet container to support them).

Craig



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Session-scoped form and synchronization...

2003-10-27 Thread Craig R. McClanahan
Peter Abbot wrote:

Generally if you are using a browser based interface to execute a
servlet requests (except if using frames) the user can only send one
request at a time. So if you are using a action with a session form and
another action wants to use that form means that the user doesn't want
the result of the previous request that might still be using the form.
 

Unfortunately, having frames is *not* the only scenario where you have 
to worry about multiple simultaneous requests.  Two simple additional ones:

* Your app contains  tags that point back into your app 
(dynamically generated images,
 for example).

* User starts a long request, presses stop, starts a second request.

Pete

 

Craig


-Original Message-
From: Manish Singla [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 28 October 2003 8:25 a.m.
To: Struts Users Mailing List
Subject: Re: Session-scoped form and synchronization...

hmmm. may be this not an bug...as struts ActionServlet extends  Java

Servlets .
And Java Servlet is not not thread safe
FYI: same goes for application attributes..



Bob Lee wrote:
 

I assume this is a bug then, because there's no way for me to do this.
It has to be done within Struts.
Bob

Kris Schneider wrote:

   

Nope, don't think so.

Quoting Bob Lee <[EMAIL PROTECTED]>:



 

Does Struts synchronize on session-scoped forms? For example, can I
assume that Stuts won't modify the fields on a session-scoped form
   

in 
 

response to one request while an action is still using it?

Thanks,
Bob
 
   



 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   



 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  1   2   3   4   5   6   7   8   9   10   >