You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ralf Hauser <ra...@gmx.ch> on 2003/04/28 10:43:45 UTC

variables in struts-config.xml? e.g. a locale variable for internationalization?

Hi,

In the process of building multi-lingual site, user feedback is of utmost
importance for us.
Therefore, we need to have different language content represented with
unique, different URLs such that for QA purposes, a user can just paste a
URL into a bug tracker/BugZilla and the maintainer of the site really knows
what language version of a page the user meant to provide feedback on.

As a first thought to do this efficiently, I would need to be able to
formulate action mappings in the struts-config.xml of the following kind:

  <action path="/myAction" type="com.psph.pl.control.action.myAction"
scope="request">
       <forward name="success" path="/index.$(locale).jsp" />
  </action>
where locale is "en" by default, but also could be "de", "fr",  etc...

Is this possible? If so, how?

Many thanks for any thoughts/experiences/recommendations in advance!

With newbie greetings r.

P.S.: I did see an approach that achieves this in the directory, not the
filename with "Tiles"
(http://nagoya.apache.org/eyebrowse/ReadMsg?listId=42&msgNo=41749, or
http://jakarta.apache.org/struts/userGuide/dev_tiles.html,
http://nagoya.apache.org/eyebrowse/ReadMsg?listId=42&msgNo=54838 ) - is this
a good approach? Could this also be applied to filenames?
P.P.S.: If I could do that, I could also use FreeMarker &
http://fmpp.sourceforge.net for managing the texts in the different
languages instead of the built-in property mechanism; this has many
interesting additional features (scripting, xml data loading, etc.).


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: variables in struts-config.xml? e.g. a locale variable for internationalization?

Posted by Ralf Hauser <ra...@gmx.ch>.
Just to wrap this up with my conclusions:

Somebody suggested to use FTL instead of JSP (read
http://freemarker.org/docs/pgui_misc_servlet.html of the FreeMarker manual
for more details).

Ralf>> How does this compare with jsp's run-time performance-wise?

> Since FTL is not compiled to byte-code, it is slower than JSP. But since
> you use it in an MVC system, it should not be significant in the end.
> Because, it is just the view
> component, it does not do too many calculations, just shows something
> that was already prepared in the action-side (and then comes the delay
> caused by the network, which is also not influenced by the view
> component). Recently, an user (an OfBiz developer) who switched from JSP
> to FTL, has said that the he has experienced 20% slow-down in the
> response time, but his page templates was complex, and he has cached the
> database queries, and AFAIK he has run the client right on the Server
> (but if not, then in a machine on the same local network), so in that
> application the view-rendering performance was more stressed than in
> usual apps. So, in general, I guess that the 99% of users should not
> worry about the performance difference. In exchange you get simpler,
> more readable templates, and far quicker first-visit response time (can
> be a good thing when you develop the templates...).
>
> Also note that unlike with FMPP, FreeMarker servlet uses cached
> pre-parsed templates. FMPP uses pre-parsed templates only for files that
> was included/imported in multiple other templates.

Since the application I am working on might be with high load, for now, I
chose to only use http://fmpp.sourceforge.net as pre-processor, but this
sounds interesting anyway!

Rgds r.
> -----Original Message-----
> From: Ralf Hauser [mailto:ralfhauser@gmx.ch]
> Sent: Montag, 28. April 2003 10:44
> To: struts-user@jakarta.apache.org
> Subject: variables in struts-config.xml? e.g. a locale variable for
> internationalization?
>
> Hi,
>
> In the process of building multi-lingual site, user feedback is of utmost
> importance for us.
> Therefore, we need to have different language content represented with
> unique, different URLs such that for QA purposes, a user can just paste a
> URL into a bug tracker/BugZilla and the maintainer of the site
> really knows
> what language version of a page the user meant to provide feedback on.
>
> As a first thought to do this efficiently, I would need to be able to
> formulate action mappings in the struts-config.xml of the following kind:
>
>   <action path="/myAction" type="com.psph.pl.control.action.myAction"
> scope="request">
>        <forward name="success" path="/index.$(locale).jsp" />
>   </action>
> where locale is "en" by default, but also could be "de", "fr",  etc...
>
> Is this possible? If so, how?
>
> Many thanks for any thoughts/experiences/recommendations in advance!
>
> With newbie greetings r.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: how to read uploaded FormFile InputStream multiple times?

Posted by Vikram Goyal <v....@uq.edu.au>.
You are better off using FileUpload from the Commons package. Using
DiskFileUpload, you can set a threshold on the size of your files. If the
threshold is breached, the files will be saved in a temp location on your
hard disk from where you can access them as many times as you want. So you
could first save them to the database and then do whatever else you want.
You could even enhance the FileUploadBase to do exactly as you want, i.e,
write to the database and then still give you a handle on a perhaps new
input stream.

--
Vikram


----- Original Message ----- 
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, October 03, 2003 3:11 PM
Subject: Re: how to read uploaded FormFile InputStream multiple times?


> Ralf Hauser wrote:
>
> >Hi,
> >
> >we use the <html:file to upload also large attachments into a web-mail
> >application.
> >First we put it into the database, but immediately thereafter, we would
like
> >to send it off to multiple recipients via encrypted mail.
> >
> >We get a "Bad File Descriptor" when trying to access the data for a
second
> >time after putting it into the database.
> >doing a inputStream.reset() gives a "java.io.IOException: mark/reset not
> >supported".
> >If we wipe the attachment from the session and get it from the (MySQL)
> >database again, reset() works beautifully and we can read it many times.
But
> >going back and forth to the database is a big waste if the InputStreams
get
> >large.
> >
> >Therefore my request to enhance the documentation in
>
>http://jakarta.apache.org/struts/api/org/apache/struts/upload/FormFile.html
#
> >getInputStream(): how can one use such an InputStream multiple times?
> >
> >Many thanks for any hints!
> >
> >
> Your best bet is to assume that you cannot *ever* read the same input
> stream more than once.  There is no guarantee in the servlet spec that
> this is possible, and it would be prohibitively expensive for a
> container to make such a guarantee, so this is not really a Struts isse
> or even a commons-fileupload issue.  It's an unwarranted assumption that
> you are making -- and such assumptions are more likely than not to be
> non-portable.
>
> The only sane thing to do is to make sure that your *application* has
> stored the uploaded file data where your *application* can find it
> again.  Expecting reset() to work is pretty much guaranteed to cause
> your application to fail.
>
> Note the emphasis in the above paragraph -- this is primarily an
> application issue, not a framework issue or a container issue.
>
> > Ralf (ralfhauser@gmx.ch)
> >
> >
> Craig
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: how to read uploaded FormFile InputStream multiple times?

Posted by "Craig R. McClanahan" <cr...@apache.org>.
Ralf Hauser wrote:

>Hi,
>
>we use the <html:file to upload also large attachments into a web-mail
>application.
>First we put it into the database, but immediately thereafter, we would like
>to send it off to multiple recipients via encrypted mail.
>
>We get a "Bad File Descriptor" when trying to access the data for a second
>time after putting it into the database.
>doing a inputStream.reset() gives a "java.io.IOException: mark/reset not
>supported".
>If we wipe the attachment from the session and get it from the (MySQL)
>database again, reset() works beautifully and we can read it many times. But
>going back and forth to the database is a big waste if the InputStreams get
>large.
>
>Therefore my request to enhance the documentation in
>http://jakarta.apache.org/struts/api/org/apache/struts/upload/FormFile.html#
>getInputStream(): how can one use such an InputStream multiple times?
>
>Many thanks for any hints!
>  
>
Your best bet is to assume that you cannot *ever* read the same input 
stream more than once.  There is no guarantee in the servlet spec that 
this is possible, and it would be prohibitively expensive for a 
container to make such a guarantee, so this is not really a Struts isse 
or even a commons-fileupload issue.  It's an unwarranted assumption that 
you are making -- and such assumptions are more likely than not to be 
non-portable.

The only sane thing to do is to make sure that your *application* has 
stored the uploaded file data where your *application* can find it 
again.  Expecting reset() to work is pretty much guaranteed to cause 
your application to fail.

Note the emphasis in the above paragraph -- this is primarily an 
application issue, not a framework issue or a container issue.

>	Ralf (ralfhauser@gmx.ch)
>  
>
Craig



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


how to read uploaded FormFile InputStream multiple times?

Posted by Ralf Hauser <ra...@gmx.ch>.
Hi,

we use the <html:file to upload also large attachments into a web-mail
application.
First we put it into the database, but immediately thereafter, we would like
to send it off to multiple recipients via encrypted mail.

We get a "Bad File Descriptor" when trying to access the data for a second
time after putting it into the database.
doing a inputStream.reset() gives a "java.io.IOException: mark/reset not
supported".
If we wipe the attachment from the session and get it from the (MySQL)
database again, reset() works beautifully and we can read it many times. But
going back and forth to the database is a big waste if the InputStreams get
large.

Therefore my request to enhance the documentation in
http://jakarta.apache.org/struts/api/org/apache/struts/upload/FormFile.html#
getInputStream(): how can one use such an InputStream multiple times?

Many thanks for any hints!

	Ralf (ralfhauser@gmx.ch)

P.S.: We figured that Blobs coming from MySQL are actually
ByteArrayInputStream thus having a reset() implemented. However, as we tried
to convert data coming from struts FormFile to ByteArrayInputStream
ourselves, it got corrupted.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org