Changing the FileUpload-Processing

2004-03-22 Thread Tim . Adler
Hello everybody!
 
I wrote to the Mailing-List some days ago. That was about the displaying of
progress-bars during fileupload. I made progress on this in that manner that
I have a patched version of the commons-fileupload-library which can do the
thing. 
 
But now I have to change the way Struts handles the FileUpload. I know that
I can overwrite the RequestProcessor and implement my own one. I hope that
it is possible to achieve my goal by doing this. What I basically need, is
the sport where Struts reads the files from the multipart-request into the
DiskFileUpload, since at this spot the progress bar tugs in.
 
Can somebody tell me a good way to do this? I know that there is a
CommonsMultipartRequestHandler which starts on doing this. But where exactly
does Struts utilize this thing?
 
Thx for any help! Hope this is not too specific.

___
Tim Adler, Abt. SDA1
Adress Management Solutions
AZ | Direct
Carl-Bertelsmann Straße 161s
D-33311 Gütersloh

Tel.: 05241/ 80 - 89574
[EMAIL PROTECTED] 

 


AW: File-Upload: Progress-Bar

2004-03-19 Thread Tim . Adler
Well that was generally what I was planning to do. The GIF-animation is
somewhat a good idea, but if I do such an server-side upload system, then I
could also do a real-percentage progress bar. I think a simple
open-window-close-window could be done with JavaScript also. But anyway
thanks for the suggestion.

Now the tricky part is: How do I do this server-side upload-system? Perhaps
you can help here also. I already implemented a singleton that keeps track
of upload-numbers for every session. So that I always have a unique
identifier combined out SessionId and Upload-Number.

My problem is tracking down the current status of an upload. Meaning: When I
upload files with Struts then the File is immediately available through the
FormFiles. Now: Is it possible to handle this upload through the
FileForm.getInputStream(). Or is the File already completely read, when I
get access to that method in the Action?! And if that is so, do I have to
parse the Multipart-Request by myself then??

-Ursprüngliche Nachricht-
Von: Max Cooper [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 19. März 2004 12:03
An: Struts Users Mailing List
Betreff: Re: File-Upload: Progress-Bar


A simpler solution that may still meet your needs might be to use an
animated GIF on a pop-up just to give the user some feedback that the upload
is still in progress and that they should be patient.

You could setup something like this:

The HTML form with upload file input element has a hidden field with some
UUID generated by the Action. The UUID is just some unique ID to avoid
having two upload forms with the same ID. For instance, the session-id or
perhaps session-id+current_time would work fine for a UUID.

Have the javascript onSubmit for the form pop-up a window, where the content
of that window will be /uploadStatus.do?UUID=234344.

Your /uploadStatus.do action will look for the UUID and forward to a JSP
with the animated GIF in it if that file has not completed uploading. That
JSP will have a meta-refresh in it that will refresh the content of the
pop-up every few seconds.

The form submit with the file upload input element will be uploading the
file for a while. When it finishes, it will indicate that the file upload
with UUID=234344 has completed to some server-side upload-tracking
subsystem. Then it will forward or redirect to whatever page the user should
see when the upload completes.

The pop-up status window will refresh itself within a second or two, and the
/uploadStatus.do action will determine that the upload for the file with
UUID=234344 has completed (by checking with the server-side upload-tracking
subsystem). It will then forward to a JSP that closes the pop-up window or
shows a message that the upload has completed.


This isn't a progress bar, but it should be easier to implement. You could
even use a fast-cycling animated GIF that looks like a progress bar (but
doesn't really relate to the actual % progress) if that would satisfy your
UI design requirements.

-Max

- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 19, 2004 1:31 AM
Subject: File-Upload: Progress-Bar


Hello everybody!

I'm up to the task to implement a progress bar for File-Uploads, cause the
files that are uploaded to my Webapp can be quite large.
Well as usual this problem is not easily solved on the HTTP-Browser upload
side.

I'm using Struts here so I'm also using the commons/FileUpload. I was
planning to do it that way that I assign a unique number to every
session's-upload and keep the current status of an upload in a singleton for
access. In an additional frame (with refresh) I would like to show the
progress bar.

My question: Has anybody done something like this with Struts before and can
give me some little advise? Or more specific: Is it possible to first get
the complete filesize from the FormFiles and the do the real Upload during
the Action (keeping track of the read bytes)

Thx for every help!!

___
Tim Adler, Abt. SDA1
Adress Management Solutions
AZ | Direct
Carl-Bertelsmann Straße 161s
D-33311 Gütersloh

Tel.: 05241/ 80 - 89574
[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]



AW: SessionTimeout handling

2004-03-19 Thread Tim . Adler
Well I simply subclassed "Action" to my own and made the session-checking
configurable through properties for the respective ActionMapping. Therefore
you simply need to subclass ActionMapping also and put this on top of your
s:



Properties will be read to the customer ActionMapping throgh reflection just
like in FormBeans.

-Ursprüngliche Nachricht-
Von: Sanoj, Antony (IE10) [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 19. März 2004 11:14
An: Struts Users Mailing List
Betreff: RE: SessionTimeout handling



I am using Struts1.1 with Tomcat5.0. The reason why I am extending
ActionServlet is to handle 
the timeout in a central place. Target environment might be Websphere 4.0. I
heard it doesn't support 
Filters. My requirement is not to propogate the session timeout handling to
action classes.

Regards, 
Sanoj Antony 




-Original Message-
From: Mark Lowe [mailto:[EMAIL PROTECTED]
Sent: Friday, March 19, 2004 3:28 PM
To: Struts Users Mailing List
Subject: Re: SessionTimeout handling


If your container supports it use a Filter. And I think (perhaps don't  
know) that session timeout is something you usually configure the  
container to do, but again i'm not sure of your requirement.



On 19 Mar 2004, at 10:48, Sanoj, Antony (IE10) wrote:

> Hi,
>
> I am trying to handle session timeout by extending the ActionServlet.
>
> I am trying to use the request method isRequestedSessionIdValid()  
> coupled with checking the session for my userbean.
>
>  Please comment about this code. Advice if there is a better way to do  
> session timeout trapping.
>
> / 
> *** 
> ***/
>
>  public boolean processPreprocess(HttpServletRequest  
> request,  HttpServletResponse response)
>  {
>
>    /* "UserBean" is a bean which represents the logged in user. */ 
>   if( request.isRequestedSessionIdValid()  
> || request.getSession().getAttribute("UserBean") != null)
>    return true;
>   else
>   {
>    try
>    {
> request.getRequestDispatcher("SessionTimeout.do").forward(request,r 
> esponse);
>    }
>     catch(Exception e)
>    {
>   e.printStackTrace();  
>    }
>    return false;
>   }
>  }
>
> / 
> *** 
> ***/
>
> Regards,
> Sanoj Antony
> -
> 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]



AW: SessionTimeout handling

2004-03-19 Thread Tim . Adler
I do something similar. I don't know which version of Struts you are using,
but I decided to create a general SessionTimeoutException and forward the
User to a SessionTimeout page when that error occurs. I'm simply configured
a GeneralFoward for the SessionTimeout page.

protected void ensureSessionSecurity(HttpServletRequest request)
throws AzDiasMinerSessionTimeoutException
{
HttpSession session = request.getSession(false);

if(session == null || session.isNew()) 
{
session.invalidate();
throw new AzDiasMinerSessionTimeoutException();
}
}

On the respective page the User can read about the Timeout. You just need to
catch and forward on this exception.

}
catch(AzDiasMinerSessionTimeoutException ase)
{
return mapping.findForward("session_timeout");

}

I also did that in a subclass of Action.
PLEASE NOTE: You have to check for isNew() cause Tomcat e.g. creates a new
session even if your call getSession() with false.  The Specs say that null
should normally be returned instead.





-Ursprüngliche Nachricht-
Von: Sanoj, Antony (IE10) [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 19. März 2004 10:48
An: [EMAIL PROTECTED]
Betreff: SessionTimeout handling


Hi,
I am trying to handle session timeout by extending the ActionServlet.
I am trying to use the request method isRequestedSessionIdValid() coupled
with checking the session for my userbean. 
Please comment about this code. Advice if there is a better way to do
session timeout trapping.
/***
***/
 public boolean processPreprocess(HttpServletRequest request,
HttpServletResponse response) 
 {
   /* "UserBean" is a bean which represents the logged in user. */  
  if( request.isRequestedSessionIdValid() ||
request.getSession().getAttribute("UserBean") != null)
   return true;
  else
  {
   try
   {
 
request.getRequestDispatcher("SessionTimeout.do").forward(request,response);
   } 
   catch(Exception e)
   {
  e.printStackTrace();  
   }
   return false;
  }
 }
/***
***/
Regards, 
Sanoj Antony 

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



File-Upload: Progress-Bar

2004-03-19 Thread Tim . Adler
Hello everybody!
 
I'm up to the task to implement a progress bar for File-Uploads, cause the
files that are uploaded to my Webapp can be quite large.
Well as usual this problem is not easily solved on the HTTP-Browser upload
side.
 
I'm using Struts here so I'm also using the commons/FileUpload. I was
planning to do it that way that I assign a unique number to every
session's-upload and keep the current status of an upload in a singleton for
access. In an additional frame (with refresh) I would like to show the
progress bar.
 
My question: Has anybody done something like this with Struts before and can
give me some little advise? Or more specific: Is it possible to first get
the complete filesize from the FormFiles and the do the real Upload during
the Action (keeping track of the read bytes)
 
Thx for every help!!

_______
Tim Adler, Abt. SDA1
Adress Management Solutions
AZ | Direct
Carl-Bertelsmann Straße 161s
D-33311 Gütersloh

Tel.: 05241/ 80 - 89574
[EMAIL PROTECTED] 

 


Struts: Session Serialization

2004-03-16 Thread Tim . Adler
Hello everybody!
 
I have noticed that my Struts integration always tries to serialize existing
sessions on undeploy of my webapp.
I started my webapp with the default that came with the struts-blank.war.
 
This serialization fails with WriteAbortedException cause some of my
session-attributes are not Serializable (don't implement it).
So my questions is, either: How do I prevent these Exceptions (like turning
off Session-Serialization in cfg)? Or should I add "Serializable" to my
not-serializable attributes, and what would be the benefit of that??
 
Thx for the help!
 
Tim

_______
Tim Adler, Abt. SDA1
Adress Management Solutions
AZ | Direct
Carl-Bertelsmann Straße 161s
D-33311 Gütersloh

Tel.: 05241/ 80 - 89574
[EMAIL PROTECTED] 

 


Own Action-Subclass: How to configure using "set-property"-elemen ts?

2004-03-08 Thread Tim . Adler
Hey everbody!
 
I derived my own Action-subclass for doing multiple stuff in my webapp on
every request. Part of the "multiple-stuff" is a method that checks if the
session got lost, but only if needed at that certain point in the
application (like when a formbean is used over multiple request for creating
an order or stuff).
Now, my current pratice is to call that method manually in every custom
action I write, which is somehow unsatisfying. I'd rather like to be able to
configure this session-safety directly through the struts-config.xml. I saw
that there are  elements, which seem like they could give me
such an ability based on every action-mapping. That'd be nice.
But HOW can I access those properties in my action?! I can't seem to find
any methods for that.
 
Thx for any help!!
___________
Tim Adler, Abt. SDA1
Adress Management Solutions
AZ | Direct
Carl-Bertelsmann Straße 161s
D-33311 Gütersloh

Tel.: 05241/ 80 - 89574
[EMAIL PROTECTED] 
 


AW: How do I access Message Resources in an Action?

2004-03-02 Thread Tim . Adler
Thx everybody!

I found that Sateesh' advise worked quite well.
I added something like this here to my ActionServlet subclass

protected String getLocalizedMessage(String key,Locale l)
{
ResourceBundle rb =
PropertyResourceBundle.getBundle("resources.application",l);
Object value = rb.getObject(key);
debug("message-resource-lookup: KEY:"+key+" VALUE:"+value);

return value.toString();
}

-Ursprüngliche Nachricht-
Von: Adam Hardy [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 2. März 2004 14:04
An: Struts Users Mailing List
Betreff: Re: How do I access Message Resources in an Action?


I could send you off to look at the Javadoc, but sometimes working stuff 
out painstaking. Here's what I do:

MessageResources resources = (MessageResources)
 context.getAttribute(Globals.MESSAGES_KEY);
String msg = resources.getMessage("my.key");

Globals.MESSAGES_KEY is the default. If you set up other bundles, just 
change it appropriately. context is the page context - I took this from 
a taglib - you'd have to convert it to the servlet context I presume.

Adam

On 03/02/2004 01:37 PM [EMAIL PROTECTED] wrote:
> Hey everybody!
> 
> Well the subject basically states my problem already. I'd like to create a
> dynamical Navigation Bar that holds some pages you visited last. Therefore
> I'd like to add Name, Link and Parameters to a Collection for later
> printing. Problem is that the Name needs to come from the Message
Resources,
> and I don't know how to access those in an Action.
>  
> Can somebody help me?!
>  
> Thx!
>  
> P.S.: Can you guys access http://java.sun.com <http://java.sun.com>  ??!
> Either my company's net is broken or the page is really down.
> 
> ___
> Tim Adler, Abt. SDA1
> Adress Management Solutions
> AZ | Direct
> Carl-Bertelsmann Straße 161s
> D-33311 Gütersloh
> 
> Tel.: 05241/ 80 - 89574
> [EMAIL PROTECTED] 
> 
>  
> 


-- 
struts 1.1 + tomcat 5.0.16 + java 1.4.2
Linux 2.4.20 Debian


-
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]



How do I access Message Resources in an Action?

2004-03-02 Thread Tim . Adler
Hey everybody!

Well the subject basically states my problem already. I'd like to create a
dynamical Navigation Bar that holds some pages you visited last. Therefore
I'd like to add Name, Link and Parameters to a Collection for later
printing. Problem is that the Name needs to come from the Message Resources,
and I don't know how to access those in an Action.
 
Can somebody help me?!
 
Thx!
 
P.S.: Can you guys access http://java.sun.com <http://java.sun.com>  ??!
Either my company's net is broken or the page is really down.

_______
Tim Adler, Abt. SDA1
Adress Management Solutions
AZ | Direct
Carl-Bertelsmann Straße 161s
D-33311 Gütersloh

Tel.: 05241/ 80 - 89574
[EMAIL PROTECTED]