You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Ilkka Priha <ip...@surfeu.fi> on 2001/04/21 18:40:48 UTC
[PATCH] Encoding in TurbineVelocityService
Below are results from our template encoding tests:
1) Velocity 1.0 supports only reading of template files from the disk using
the host enviroment's default encoding, which can be changed in OS specific
way as stated by Rafal. An encoding that always works with Java files, is
the unicode '\uxxxx' format. This requires a separate transfomation as no
one wants to write and maintain such files.
Velocity 1.1 has a new property, input.encoding, with which to specify an
explicit encoding for reading templates. As only one encoding is supported,
the most applicable one is probably UTF-8, which can be used for any
language. This may also require a separate transformation, if the orginal
content is produced with some national encoding, like Shift_JIS or Big5.
Velocity has the functionality to use different encodings on a request by
request basis, but how to utilize this in Turbine is still a bit open.
However, the Velocity service can be programmed to be compatible with both
1.0 and 1.1 by letting it just pass a configuration with appropriate
properties to Velocity.
2) The locale specific encoding support, with which to specify the encoding
to use for the response to be passed to the client browser, is included in
the default RunData implementation and seems to work quite nicely. We've
changed the Velocity service to use this support and tested it with UTF-8,
ISO-8859-5 and Shift_JIS both with HTML and WML. It's cool to have a server
supporting English, Russian and Japanese for web browsers and wap phones at
the same time.
The required changes to TurbineVelocityService are below. Now I'd like to
have comments whether to include these changes in 2.1? Personally, I'd like
to include them as they don't alter existing template processing, if
locale/charset properties are not used, but make turbine to process
templates correctly, when they are used.
-- Ilkka
--- TurbineVelocityService.old Sat Apr 21 12:27:58 2001
+++ TurbineVelocityService.new Sat Apr 21 12:17:21 2001
@@ -105,17 +105,7 @@
implements VelocityService
{
/**
- * Default encoding to use. This is the default for Velocity,
- * Right now I'm not sure if Turbine considers encoding.
- * This encoding will be taken from the Velocity service
- * properties, the defaultEncoding will be used if it
- * isn't specified.
- */
- private String encoding;
-
- /**
- * Default encoding to use. This is the default for Velocity,
- * Right now I'm not sure if Turbine considers encoding.
+ * Default encoding to use if not specified in the RunData object.
*/
private String defaultEncoding = "ISO-8859-1";
@@ -252,21 +242,13 @@
public String handleRequest(Context context, String filename)
throws TurbineException
{
- /*
- * This is for development.
- */
- if (pullModelActive && refreshToolsPerRequest)
- {
- TurbinePull.refreshGlobalTools();
- }
-
String results = null;
ByteArrayOutputStream bytes = null;
try
{
bytes = new ByteArrayOutputStream();
- handleRequest(context, filename, bytes);
+ String encoding = encodeRequest(context, filename, bytes);
results = bytes.toString(encoding);
}
catch(Exception e)
@@ -303,7 +285,27 @@
OutputStream output)
throws TurbineException
{
-
+ encodeRequest(context, filename, output);
+ }
+
+ /**
+ * Process the request and fill in the template with the values
+ * you set in the Context. Apply the encoding from RunData to the
result.
+ *
+ * @param context A Context.
+ * @param filename A String with the filename of the template.
+ * @param out A OutputStream where we will write the process template
as
+ * a String.
+ * @return The character encoding applied to the resulting String.
+ *
+ * @throws TurbineException Any exception trown while processing will
be
+ * wrapped into a TurbineException and rethrown.
+ */
+ private String encodeRequest(Context context,
+ String filename,
+ OutputStream output)
+ throws TurbineException
+ {
/*
* This is for development.
*/
@@ -311,7 +313,26 @@
{
TurbinePull.refreshGlobalTools();
}
-
+
+ /*
+ * Get the encoding from the RunData object.
+ */
+ String encoding;
+ Object data = context.get("data");
+ if ((data != null) &&
+ (data instanceof RunData))
+ {
+ encoding = ((RunData) data).getCharSet();
+ if (encoding == null)
+ {
+ encoding = defaultEncoding;
+ }
+ }
+ else
+ {
+ encoding = defaultEncoding;
+ }
+
OutputStreamWriter writer = null;
try
@@ -339,6 +360,8 @@
*/
}
}
+
+ return encoding;
}
/**
@@ -370,15 +393,6 @@
* Get the configuration for this service.
*/
Configuration configuration = getConfiguration();
-
- /*
- * Set the encoding to use according to the property specified
- * for in the Velocity service configuration. This property
- * should probably be melded with the default char set
- * property already used in the velocity service.
- */
- encoding = configuration.getString(
- "template.encoding", defaultEncoding);
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: [PATCH] Encoding in TurbineVelocityService
Posted by Santiago Gala <sg...@hisitech.com>.
Ilkka Priha wrote:
> The parameter parser uses servlet engine's parameters as such and they should be
> automatically correct as the request contains a Content-Type header for the
> request body specifying also the character set if it's something else than the
> default. For POSTs, it should be the same, which was given in the corresponding
> response.
>
> If you let the upload service to parse the parameters by having a property
>
> services.UploadService.automatic=true
>
> in TR, then it might not work as the default implementation of the service
> doesn't seem to check the req.getCharacterEncoding().
>
> It's also possible to set the form encoding with the ENCTYPE attribute and
> (maybe) to append the character set to it (haven't tried this, because I haven't
> had problems with encoding of form parameters):
>
> <FORM enctype="application/x-www-form-urlencoded; charset=ISO-8859-7">
> ...
> </FORM>
>
We have done this in Jetspeed, to enforce UTF-8, and it works reasonably
with the tested user agents.
<form accept-charset="UTF-8, ISO-8859-1" ...
to enforce that the POSTED response comes with the proper encoding set.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
ResourceService and getConfiguration()
Posted by Ilkka Priha <ip...@surfeu.fi>.
BaseService provides a default implementation of the Service interface including
the getConfiguration() method. The returned Configuration should contain service
specific properties obtained via ServiceBroker from ResourceService. The
returned Configuration is generally a new instance, which can be modified
without side effects to other objects.
TurbineResourceService implements also the getConfiguration() method, which
returns a direct reference to its internal Configuration object maintaining
properties of all other services. This is a useful implementation especially for
subclasses extending ResourceService, but should it have a different name, like
getResourceConfiguration(), that wouldn't hide the default implementation, which
would return only the properties of ResourceService itself as specified in the
Service interface?
-- Ilkka
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: [PATCH] Encoding in TurbineVelocityService
Posted by Costas Stergiou <cs...@aias.gr>.
I use tomcat 3.2.1 and as far as I know (by experince) it doesn't do so.
I am not ready to use Catalina in a production environment yet...
----- Original Message -----
From: "Ilkka Priha" <ip...@surfeu.fi>
To: <tu...@jakarta.apache.org>
Sent: Monday, April 23, 2001 1:09 PM
Subject: RE: [PATCH] Encoding in TurbineVelocityService
> Hmm, are you sure? At least Catalina (Tomcat 4.0) parses parameters using
the
> encoding of the request:
>
> /**
> * Parse the parameters of this request, if it has not already
occurred.
> * If parameters are present in both the query string and the request
> * content, they are merged.
> */
> protected void parseParameters() {
>
> **** CUT ****
>
> String encoding = getCharacterEncoding();
> if (encoding == null)
> RequestUtil.parseParameters
> (results, new String(buf), false);
> else
> RequestUtil.parseParameters
> (results, new String(buf, encoding), false);
> } catch (Throwable t) {
> ;
> }
>
> -- Ilkka
>
>
> -----Original Message-----
> From: Costas Stergiou [mailto:csterg@aias.gr]
> Sent: 23. huhtikuuta 2001 12:35
> To: turbine-dev@jakarta.apache.org; ext-ilkka.priha@nokia.com
> Subject: Re: [PATCH] Encoding in TurbineVelocityService
>
>
> Actually, tomcat always uses the 8859_1 encoding. I think it does
> so even when the OS locale is different. I don't think it looks
> at the Content-Type header at all.
>
>
> ----- Original Message -----
> From: "Ilkka Priha" <ex...@nokia.com>
> To: <tu...@jakarta.apache.org>
> Sent: Monday, April 23, 2001 11:31 AM
> Subject: RE: [PATCH] Encoding in TurbineVelocityService
>
>
> > The parameter parser uses servlet engine's parameters as such and they
> should be
> > automatically correct as the request contains a Content-Type header for
> the
> > request body specifying also the character set if it's something else
than
> the
> > default. For POSTs, it should be the same, which was given in the
> corresponding
> > response.
> >
> > If you let the upload service to parse the parameters by having a
property
> >
> > services.UploadService.automatic=true
> >
> > in TR, then it might not work as the default implementation of the
service
> > doesn't seem to check the req.getCharacterEncoding().
> >
> > It's also possible to set the form encoding with the ENCTYPE attribute
and
> > (maybe) to append the character set to it (haven't tried this, because I
> haven't
> > had problems with encoding of form parameters):
> >
> > <FORM enctype="application/x-www-form-urlencoded; charset=ISO-8859-7">
> > ...
> > </FORM>
> >
> > -- Ilkka
> >
> >
> > -----Original Message-----
> > From: Costas Stergiou [mailto:csterg@aias.gr]
> > Sent: 23. huhtikuuta 2001 9:31
> > To: turbine-dev@jakarta.apache.org
> > Subject: Re: [PATCH] Encoding in TurbineVelocityService
> >
> >
> > Hi,
> > I think this is very good work and absolutely necessary for Turbine...
> > I would like to ask if you gave any thoughts to the encoding that
> > the ParameterParser (BaseValueParser) uses to encode the parameters
> > sent back by the broswer. I don't think that there is a way
> > right now to specify the encoding that is used there. There should
> > be a way to specify the encoding to use for reading the request
> > parameters, per request. I am not sure how can this be accomplished
> > since the ParameterParser reads all the parameters from the request
> > before any action is called.
> > For example, a hidden parameter could
> > be used in the html that specifies the encoding (the one that we think
> > the client is using) in order to read back the parameters. But, how we
> > could we use this to decide the encoding before actually reading the
> > parameters in the ParameterParser???
> >
> > Any thoughts on that. Maybe there is already something that
> > I am not aware of.
> > Thanks,
> > Costas
> >
> > ----- Original Message -----
> > From: "Ilkka Priha" <ip...@surfeu.fi>
> > To: "Dev Turbine" <tu...@jakarta.apache.org>
> > Sent: Saturday, April 21, 2001 7:40 PM
> > Subject: [PATCH] Encoding in TurbineVelocityService
> >
> >
> > > Below are results from our template encoding tests:
> > >
> > > 1) Velocity 1.0 supports only reading of template files from the disk
> > using
> > > the host enviroment's default encoding, which can be changed in OS
> > specific
> > > way as stated by Rafal. An encoding that always works with Java files,
> is
> > > the unicode '\uxxxx' format. This requires a separate transfomation as
> no
> > > one wants to write and maintain such files.
> > >
> > > Velocity 1.1 has a new property, input.encoding, with which to specify
> an
> > > explicit encoding for reading templates. As only one encoding is
> > supported,
> > > the most applicable one is probably UTF-8, which can be used for any
> > > language. This may also require a separate transformation, if the
> orginal
> > > content is produced with some national encoding, like Shift_JIS or
Big5.
> > >
> > > Velocity has the functionality to use different encodings on a request
> by
> > > request basis, but how to utilize this in Turbine is still a bit open.
> > > However, the Velocity service can be programmed to be compatible with
> both
> > > 1.0 and 1.1 by letting it just pass a configuration with appropriate
> > > properties to Velocity.
> > >
> > > 2) The locale specific encoding support, with which to specify the
> > encoding
> > > to use for the response to be passed to the client browser, is
included
> in
> > > the default RunData implementation and seems to work quite nicely.
We've
> > > changed the Velocity service to use this support and tested it with
> UTF-8,
> > > ISO-8859-5 and Shift_JIS both with HTML and WML. It's cool to have a
> > server
> > > supporting English, Russian and Japanese for web browsers and wap
phones
> > at
> > > the same time.
> > >
> > > The required changes to TurbineVelocityService are below. Now I'd like
> to
> > > have comments whether to include these changes in 2.1? Personally, I'd
> > like
> > > to include them as they don't alter existing template processing, if
> > > locale/charset properties are not used, but make turbine to process
> > > templates correctly, when they are used.
> > >
> > > -- Ilkka
> > >
> > >
> > > --- TurbineVelocityService.old Sat Apr 21 12:27:58 2001
> > > +++ TurbineVelocityService.new Sat Apr 21 12:17:21 2001
> > > @@ -105,17 +105,7 @@
> > > implements VelocityService
> > > {
> > > /**
> > > - * Default encoding to use. This is the default for Velocity,
> > > - * Right now I'm not sure if Turbine considers encoding.
> > > - * This encoding will be taken from the Velocity service
> > > - * properties, the defaultEncoding will be used if it
> > > - * isn't specified.
> > > - */
> > > - private String encoding;
> > > -
> > > - /**
> > > - * Default encoding to use. This is the default for Velocity,
> > > - * Right now I'm not sure if Turbine considers encoding.
> > > + * Default encoding to use if not specified in the RunData
object.
> > > */
> > > private String defaultEncoding = "ISO-8859-1";
> > >
> > > @@ -252,21 +242,13 @@
> > > public String handleRequest(Context context, String filename)
> > > throws TurbineException
> > > {
> > > - /*
> > > - * This is for development.
> > > - */
> > > - if (pullModelActive && refreshToolsPerRequest)
> > > - {
> > > - TurbinePull.refreshGlobalTools();
> > > - }
> > > -
> > > String results = null;
> > > ByteArrayOutputStream bytes = null;
> > >
> > > try
> > > {
> > > bytes = new ByteArrayOutputStream();
> > > - handleRequest(context, filename, bytes);
> > > + String encoding = encodeRequest(context, filename,
bytes);
> > > results = bytes.toString(encoding);
> > > }
> > > catch(Exception e)
> > > @@ -303,7 +285,27 @@
> > > OutputStream output)
> > > throws TurbineException
> > > {
> > > -
> > > + encodeRequest(context, filename, output);
> > > + }
> > > +
> > > + /**
> > > + * Process the request and fill in the template with the values
> > > + * you set in the Context. Apply the encoding from RunData to the
> > > result.
> > > + *
> > > + * @param context A Context.
> > > + * @param filename A String with the filename of the template.
> > > + * @param out A OutputStream where we will write the process
> template
> > > as
> > > + * a String.
> > > + * @return The character encoding applied to the resulting
String.
> > > + *
> > > + * @throws TurbineException Any exception trown while processing
> will
> > > be
> > > + * wrapped into a TurbineException and rethrown.
> > > + */
> > > + private String encodeRequest(Context context,
> > > + String filename,
> > > + OutputStream output)
> > > + throws TurbineException
> > > + {
> > > /*
> > > * This is for development.
> > > */
> > > @@ -311,7 +313,26 @@
> > > {
> > > TurbinePull.refreshGlobalTools();
> > > }
> > > -
> > > +
> > > + /*
> > > + * Get the encoding from the RunData object.
> > > + */
> > > + String encoding;
> > > + Object data = context.get("data");
> > > + if ((data != null) &&
> > > + (data instanceof RunData))
> > > + {
> > > + encoding = ((RunData) data).getCharSet();
> > > + if (encoding == null)
> > > + {
> > > + encoding = defaultEncoding;
> > > + }
> > > + }
> > > + else
> > > + {
> > > + encoding = defaultEncoding;
> > > + }
> > > +
> > > OutputStreamWriter writer = null;
> > >
> > > try
> > > @@ -339,6 +360,8 @@
> > > */
> > > }
> > > }
> > > +
> > > + return encoding;
> > > }
> > >
> > > /**
> > > @@ -370,15 +393,6 @@
> > > * Get the configuration for this service.
> > > */
> > > Configuration configuration = getConfiguration();
> > > -
> > > - /*
> > > - * Set the encoding to use according to the property
specified
> > > - * for in the Velocity service configuration. This property
> > > - * should probably be melded with the default char set
> > > - * property already used in the velocity service.
> > > - */
> > > - encoding = configuration.getString(
> > > - "template.encoding", defaultEncoding);
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
RE: [PATCH] Encoding in TurbineVelocityService
Posted by Ilkka Priha <ip...@surfeu.fi>.
Hmm, are you sure? At least Catalina (Tomcat 4.0) parses parameters using the
encoding of the request:
/**
* Parse the parameters of this request, if it has not already occurred.
* If parameters are present in both the query string and the request
* content, they are merged.
*/
protected void parseParameters() {
**** CUT ****
String encoding = getCharacterEncoding();
if (encoding == null)
RequestUtil.parseParameters
(results, new String(buf), false);
else
RequestUtil.parseParameters
(results, new String(buf, encoding), false);
} catch (Throwable t) {
;
}
-- Ilkka
-----Original Message-----
From: Costas Stergiou [mailto:csterg@aias.gr]
Sent: 23. huhtikuuta 2001 12:35
To: turbine-dev@jakarta.apache.org; ext-ilkka.priha@nokia.com
Subject: Re: [PATCH] Encoding in TurbineVelocityService
Actually, tomcat always uses the 8859_1 encoding. I think it does
so even when the OS locale is different. I don't think it looks
at the Content-Type header at all.
----- Original Message -----
From: "Ilkka Priha" <ex...@nokia.com>
To: <tu...@jakarta.apache.org>
Sent: Monday, April 23, 2001 11:31 AM
Subject: RE: [PATCH] Encoding in TurbineVelocityService
> The parameter parser uses servlet engine's parameters as such and they
should be
> automatically correct as the request contains a Content-Type header for
the
> request body specifying also the character set if it's something else than
the
> default. For POSTs, it should be the same, which was given in the
corresponding
> response.
>
> If you let the upload service to parse the parameters by having a property
>
> services.UploadService.automatic=true
>
> in TR, then it might not work as the default implementation of the service
> doesn't seem to check the req.getCharacterEncoding().
>
> It's also possible to set the form encoding with the ENCTYPE attribute and
> (maybe) to append the character set to it (haven't tried this, because I
haven't
> had problems with encoding of form parameters):
>
> <FORM enctype="application/x-www-form-urlencoded; charset=ISO-8859-7">
> ...
> </FORM>
>
> -- Ilkka
>
>
> -----Original Message-----
> From: Costas Stergiou [mailto:csterg@aias.gr]
> Sent: 23. huhtikuuta 2001 9:31
> To: turbine-dev@jakarta.apache.org
> Subject: Re: [PATCH] Encoding in TurbineVelocityService
>
>
> Hi,
> I think this is very good work and absolutely necessary for Turbine...
> I would like to ask if you gave any thoughts to the encoding that
> the ParameterParser (BaseValueParser) uses to encode the parameters
> sent back by the broswer. I don't think that there is a way
> right now to specify the encoding that is used there. There should
> be a way to specify the encoding to use for reading the request
> parameters, per request. I am not sure how can this be accomplished
> since the ParameterParser reads all the parameters from the request
> before any action is called.
> For example, a hidden parameter could
> be used in the html that specifies the encoding (the one that we think
> the client is using) in order to read back the parameters. But, how we
> could we use this to decide the encoding before actually reading the
> parameters in the ParameterParser???
>
> Any thoughts on that. Maybe there is already something that
> I am not aware of.
> Thanks,
> Costas
>
> ----- Original Message -----
> From: "Ilkka Priha" <ip...@surfeu.fi>
> To: "Dev Turbine" <tu...@jakarta.apache.org>
> Sent: Saturday, April 21, 2001 7:40 PM
> Subject: [PATCH] Encoding in TurbineVelocityService
>
>
> > Below are results from our template encoding tests:
> >
> > 1) Velocity 1.0 supports only reading of template files from the disk
> using
> > the host enviroment's default encoding, which can be changed in OS
> specific
> > way as stated by Rafal. An encoding that always works with Java files,
is
> > the unicode '\uxxxx' format. This requires a separate transfomation as
no
> > one wants to write and maintain such files.
> >
> > Velocity 1.1 has a new property, input.encoding, with which to specify
an
> > explicit encoding for reading templates. As only one encoding is
> supported,
> > the most applicable one is probably UTF-8, which can be used for any
> > language. This may also require a separate transformation, if the
orginal
> > content is produced with some national encoding, like Shift_JIS or Big5.
> >
> > Velocity has the functionality to use different encodings on a request
by
> > request basis, but how to utilize this in Turbine is still a bit open.
> > However, the Velocity service can be programmed to be compatible with
both
> > 1.0 and 1.1 by letting it just pass a configuration with appropriate
> > properties to Velocity.
> >
> > 2) The locale specific encoding support, with which to specify the
> encoding
> > to use for the response to be passed to the client browser, is included
in
> > the default RunData implementation and seems to work quite nicely. We've
> > changed the Velocity service to use this support and tested it with
UTF-8,
> > ISO-8859-5 and Shift_JIS both with HTML and WML. It's cool to have a
> server
> > supporting English, Russian and Japanese for web browsers and wap phones
> at
> > the same time.
> >
> > The required changes to TurbineVelocityService are below. Now I'd like
to
> > have comments whether to include these changes in 2.1? Personally, I'd
> like
> > to include them as they don't alter existing template processing, if
> > locale/charset properties are not used, but make turbine to process
> > templates correctly, when they are used.
> >
> > -- Ilkka
> >
> >
> > --- TurbineVelocityService.old Sat Apr 21 12:27:58 2001
> > +++ TurbineVelocityService.new Sat Apr 21 12:17:21 2001
> > @@ -105,17 +105,7 @@
> > implements VelocityService
> > {
> > /**
> > - * Default encoding to use. This is the default for Velocity,
> > - * Right now I'm not sure if Turbine considers encoding.
> > - * This encoding will be taken from the Velocity service
> > - * properties, the defaultEncoding will be used if it
> > - * isn't specified.
> > - */
> > - private String encoding;
> > -
> > - /**
> > - * Default encoding to use. This is the default for Velocity,
> > - * Right now I'm not sure if Turbine considers encoding.
> > + * Default encoding to use if not specified in the RunData object.
> > */
> > private String defaultEncoding = "ISO-8859-1";
> >
> > @@ -252,21 +242,13 @@
> > public String handleRequest(Context context, String filename)
> > throws TurbineException
> > {
> > - /*
> > - * This is for development.
> > - */
> > - if (pullModelActive && refreshToolsPerRequest)
> > - {
> > - TurbinePull.refreshGlobalTools();
> > - }
> > -
> > String results = null;
> > ByteArrayOutputStream bytes = null;
> >
> > try
> > {
> > bytes = new ByteArrayOutputStream();
> > - handleRequest(context, filename, bytes);
> > + String encoding = encodeRequest(context, filename, bytes);
> > results = bytes.toString(encoding);
> > }
> > catch(Exception e)
> > @@ -303,7 +285,27 @@
> > OutputStream output)
> > throws TurbineException
> > {
> > -
> > + encodeRequest(context, filename, output);
> > + }
> > +
> > + /**
> > + * Process the request and fill in the template with the values
> > + * you set in the Context. Apply the encoding from RunData to the
> > result.
> > + *
> > + * @param context A Context.
> > + * @param filename A String with the filename of the template.
> > + * @param out A OutputStream where we will write the process
template
> > as
> > + * a String.
> > + * @return The character encoding applied to the resulting String.
> > + *
> > + * @throws TurbineException Any exception trown while processing
will
> > be
> > + * wrapped into a TurbineException and rethrown.
> > + */
> > + private String encodeRequest(Context context,
> > + String filename,
> > + OutputStream output)
> > + throws TurbineException
> > + {
> > /*
> > * This is for development.
> > */
> > @@ -311,7 +313,26 @@
> > {
> > TurbinePull.refreshGlobalTools();
> > }
> > -
> > +
> > + /*
> > + * Get the encoding from the RunData object.
> > + */
> > + String encoding;
> > + Object data = context.get("data");
> > + if ((data != null) &&
> > + (data instanceof RunData))
> > + {
> > + encoding = ((RunData) data).getCharSet();
> > + if (encoding == null)
> > + {
> > + encoding = defaultEncoding;
> > + }
> > + }
> > + else
> > + {
> > + encoding = defaultEncoding;
> > + }
> > +
> > OutputStreamWriter writer = null;
> >
> > try
> > @@ -339,6 +360,8 @@
> > */
> > }
> > }
> > +
> > + return encoding;
> > }
> >
> > /**
> > @@ -370,15 +393,6 @@
> > * Get the configuration for this service.
> > */
> > Configuration configuration = getConfiguration();
> > -
> > - /*
> > - * Set the encoding to use according to the property specified
> > - * for in the Velocity service configuration. This property
> > - * should probably be melded with the default char set
> > - * property already used in the velocity service.
> > - */
> > - encoding = configuration.getString(
> > - "template.encoding", defaultEncoding);
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: [PATCH] Encoding in TurbineVelocityService
Posted by Costas Stergiou <cs...@aias.gr>.
Actually, tomcat always uses the 8859_1 encoding. I think it does
so even when the OS locale is different. I don't think it looks
at the Content-Type header at all.
----- Original Message -----
From: "Ilkka Priha" <ex...@nokia.com>
To: <tu...@jakarta.apache.org>
Sent: Monday, April 23, 2001 11:31 AM
Subject: RE: [PATCH] Encoding in TurbineVelocityService
> The parameter parser uses servlet engine's parameters as such and they
should be
> automatically correct as the request contains a Content-Type header for
the
> request body specifying also the character set if it's something else than
the
> default. For POSTs, it should be the same, which was given in the
corresponding
> response.
>
> If you let the upload service to parse the parameters by having a property
>
> services.UploadService.automatic=true
>
> in TR, then it might not work as the default implementation of the service
> doesn't seem to check the req.getCharacterEncoding().
>
> It's also possible to set the form encoding with the ENCTYPE attribute and
> (maybe) to append the character set to it (haven't tried this, because I
haven't
> had problems with encoding of form parameters):
>
> <FORM enctype="application/x-www-form-urlencoded; charset=ISO-8859-7">
> ...
> </FORM>
>
> -- Ilkka
>
>
> -----Original Message-----
> From: Costas Stergiou [mailto:csterg@aias.gr]
> Sent: 23. huhtikuuta 2001 9:31
> To: turbine-dev@jakarta.apache.org
> Subject: Re: [PATCH] Encoding in TurbineVelocityService
>
>
> Hi,
> I think this is very good work and absolutely necessary for Turbine...
> I would like to ask if you gave any thoughts to the encoding that
> the ParameterParser (BaseValueParser) uses to encode the parameters
> sent back by the broswer. I don't think that there is a way
> right now to specify the encoding that is used there. There should
> be a way to specify the encoding to use for reading the request
> parameters, per request. I am not sure how can this be accomplished
> since the ParameterParser reads all the parameters from the request
> before any action is called.
> For example, a hidden parameter could
> be used in the html that specifies the encoding (the one that we think
> the client is using) in order to read back the parameters. But, how we
> could we use this to decide the encoding before actually reading the
> parameters in the ParameterParser???
>
> Any thoughts on that. Maybe there is already something that
> I am not aware of.
> Thanks,
> Costas
>
> ----- Original Message -----
> From: "Ilkka Priha" <ip...@surfeu.fi>
> To: "Dev Turbine" <tu...@jakarta.apache.org>
> Sent: Saturday, April 21, 2001 7:40 PM
> Subject: [PATCH] Encoding in TurbineVelocityService
>
>
> > Below are results from our template encoding tests:
> >
> > 1) Velocity 1.0 supports only reading of template files from the disk
> using
> > the host enviroment's default encoding, which can be changed in OS
> specific
> > way as stated by Rafal. An encoding that always works with Java files,
is
> > the unicode '\uxxxx' format. This requires a separate transfomation as
no
> > one wants to write and maintain such files.
> >
> > Velocity 1.1 has a new property, input.encoding, with which to specify
an
> > explicit encoding for reading templates. As only one encoding is
> supported,
> > the most applicable one is probably UTF-8, which can be used for any
> > language. This may also require a separate transformation, if the
orginal
> > content is produced with some national encoding, like Shift_JIS or Big5.
> >
> > Velocity has the functionality to use different encodings on a request
by
> > request basis, but how to utilize this in Turbine is still a bit open.
> > However, the Velocity service can be programmed to be compatible with
both
> > 1.0 and 1.1 by letting it just pass a configuration with appropriate
> > properties to Velocity.
> >
> > 2) The locale specific encoding support, with which to specify the
> encoding
> > to use for the response to be passed to the client browser, is included
in
> > the default RunData implementation and seems to work quite nicely. We've
> > changed the Velocity service to use this support and tested it with
UTF-8,
> > ISO-8859-5 and Shift_JIS both with HTML and WML. It's cool to have a
> server
> > supporting English, Russian and Japanese for web browsers and wap phones
> at
> > the same time.
> >
> > The required changes to TurbineVelocityService are below. Now I'd like
to
> > have comments whether to include these changes in 2.1? Personally, I'd
> like
> > to include them as they don't alter existing template processing, if
> > locale/charset properties are not used, but make turbine to process
> > templates correctly, when they are used.
> >
> > -- Ilkka
> >
> >
> > --- TurbineVelocityService.old Sat Apr 21 12:27:58 2001
> > +++ TurbineVelocityService.new Sat Apr 21 12:17:21 2001
> > @@ -105,17 +105,7 @@
> > implements VelocityService
> > {
> > /**
> > - * Default encoding to use. This is the default for Velocity,
> > - * Right now I'm not sure if Turbine considers encoding.
> > - * This encoding will be taken from the Velocity service
> > - * properties, the defaultEncoding will be used if it
> > - * isn't specified.
> > - */
> > - private String encoding;
> > -
> > - /**
> > - * Default encoding to use. This is the default for Velocity,
> > - * Right now I'm not sure if Turbine considers encoding.
> > + * Default encoding to use if not specified in the RunData object.
> > */
> > private String defaultEncoding = "ISO-8859-1";
> >
> > @@ -252,21 +242,13 @@
> > public String handleRequest(Context context, String filename)
> > throws TurbineException
> > {
> > - /*
> > - * This is for development.
> > - */
> > - if (pullModelActive && refreshToolsPerRequest)
> > - {
> > - TurbinePull.refreshGlobalTools();
> > - }
> > -
> > String results = null;
> > ByteArrayOutputStream bytes = null;
> >
> > try
> > {
> > bytes = new ByteArrayOutputStream();
> > - handleRequest(context, filename, bytes);
> > + String encoding = encodeRequest(context, filename, bytes);
> > results = bytes.toString(encoding);
> > }
> > catch(Exception e)
> > @@ -303,7 +285,27 @@
> > OutputStream output)
> > throws TurbineException
> > {
> > -
> > + encodeRequest(context, filename, output);
> > + }
> > +
> > + /**
> > + * Process the request and fill in the template with the values
> > + * you set in the Context. Apply the encoding from RunData to the
> > result.
> > + *
> > + * @param context A Context.
> > + * @param filename A String with the filename of the template.
> > + * @param out A OutputStream where we will write the process
template
> > as
> > + * a String.
> > + * @return The character encoding applied to the resulting String.
> > + *
> > + * @throws TurbineException Any exception trown while processing
will
> > be
> > + * wrapped into a TurbineException and rethrown.
> > + */
> > + private String encodeRequest(Context context,
> > + String filename,
> > + OutputStream output)
> > + throws TurbineException
> > + {
> > /*
> > * This is for development.
> > */
> > @@ -311,7 +313,26 @@
> > {
> > TurbinePull.refreshGlobalTools();
> > }
> > -
> > +
> > + /*
> > + * Get the encoding from the RunData object.
> > + */
> > + String encoding;
> > + Object data = context.get("data");
> > + if ((data != null) &&
> > + (data instanceof RunData))
> > + {
> > + encoding = ((RunData) data).getCharSet();
> > + if (encoding == null)
> > + {
> > + encoding = defaultEncoding;
> > + }
> > + }
> > + else
> > + {
> > + encoding = defaultEncoding;
> > + }
> > +
> > OutputStreamWriter writer = null;
> >
> > try
> > @@ -339,6 +360,8 @@
> > */
> > }
> > }
> > +
> > + return encoding;
> > }
> >
> > /**
> > @@ -370,15 +393,6 @@
> > * Get the configuration for this service.
> > */
> > Configuration configuration = getConfiguration();
> > -
> > - /*
> > - * Set the encoding to use according to the property specified
> > - * for in the Velocity service configuration. This property
> > - * should probably be melded with the default char set
> > - * property already used in the velocity service.
> > - */
> > - encoding = configuration.getString(
> > - "template.encoding", defaultEncoding);
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: Flux problems
Posted by John McNally <jm...@collab.net>.
It appears you are not defining a service that is being used. Compare
your TurbineResources.properties file against the latest version.
john mcnally
Gareth Coltman wrote:
>
> Hi,
>
> I'm still having problems, but am making progress. I think the thing that is
> confusing me in general is that when an update is made (that I really need),
> I'm not sure what I need to update.
>
> Anyway, a history:
>
> - I managed to have the "build-project init" populate an oracle database
> with turbine tables.
>
> - Upon accessing the standard flux screen (turbine data manager) I
> successfully logged on, but was unable to write data (add a user) with the
> same old sql error - unable to insert null into ID field. I still have no
> idea why it might be trying to insert null. ???!!!!
>
> - I updated my Turbine jar to the latest version.
>
> - Upon trying to rebuild, the flux action classes would not compile, so I
> update all my flux src code.
>
> - It rebuilt successfully, but now I get the following exception in the
> browser after entering the username and password (Turbine, Turbine):
>
> A Servlet Exception Has Occurred
> Exception Report:
> javax.servlet.ServletException: Servlet execution threw an exception
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:271)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:191)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:254)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:201)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
> .java:468)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
> at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2087)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
> )
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :162)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
> at
> org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
> 818)
> at
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:897)
> at java.lang.Thread.run(Thread.java:484)
>
> Root Cause:
> org.apache.turbine.services.InstantiationException: ServiceBroker: unknown
> service PoolService requested
> at
> org.apache.turbine.services.BaseServiceBroker.getServiceInstance(BaseService
> Broker.java:312)
> at
> org.apache.turbine.services.BaseServiceBroker.getService(BaseServiceBroker.j
> ava:257)
> at
> org.apache.turbine.util.RunDataFactory.putRunData(RunDataFactory.java:232)
> at org.apache.turbine.Turbine.doGet(Turbine.java:517)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:246)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:191)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:254)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:201)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
> .java:468)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
> at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2087)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
> )
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :162)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
> at
> org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
> 818)
> at
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:897)
> at java.lang.Thread.run(Thread.java:484)
>
> and no error in the log (!?)
>
> Also, Turbine keeps printing the following notice upon first access (to
> stdout):
>
> NOTICE: Initializing service (late): LoggingService
>
> All I want is to use Turbine's user management system. If it is easier for
> me to go back to my old version of Turbine and fix it myself, I'm happy to
> do so.
>
> Please let me know if you've experienced anything similar.
>
> Gareth
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Flux problems
Posted by Gareth Coltman <ga...@majorband.co.uk>.
Hi,
I'm still having problems, but am making progress. I think the thing that is
confusing me in general is that when an update is made (that I really need),
I'm not sure what I need to update.
Anyway, a history:
- I managed to have the "build-project init" populate an oracle database
with turbine tables.
- Upon accessing the standard flux screen (turbine data manager) I
successfully logged on, but was unable to write data (add a user) with the
same old sql error - unable to insert null into ID field. I still have no
idea why it might be trying to insert null. ???!!!!
- I updated my Turbine jar to the latest version.
- Upon trying to rebuild, the flux action classes would not compile, so I
update all my flux src code.
- It rebuilt successfully, but now I get the following exception in the
browser after entering the username and password (Turbine, Turbine):
A Servlet Exception Has Occurred
Exception Report:
javax.servlet.ServletException: Servlet execution threw an exception
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:271)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:191)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:254)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:201)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2087)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:162)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
818)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:897)
at java.lang.Thread.run(Thread.java:484)
Root Cause:
org.apache.turbine.services.InstantiationException: ServiceBroker: unknown
service PoolService requested
at
org.apache.turbine.services.BaseServiceBroker.getServiceInstance(BaseService
Broker.java:312)
at
org.apache.turbine.services.BaseServiceBroker.getService(BaseServiceBroker.j
ava:257)
at
org.apache.turbine.util.RunDataFactory.putRunData(RunDataFactory.java:232)
at org.apache.turbine.Turbine.doGet(Turbine.java:517)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:246)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:191)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:254)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:201)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2087)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:162)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
818)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:897)
at java.lang.Thread.run(Thread.java:484)
and no error in the log (!?)
Also, Turbine keeps printing the following notice upon first access (to
stdout):
NOTICE: Initializing service (late): LoggingService
All I want is to use Turbine's user management system. If it is easier for
me to go back to my old version of Turbine and fix it myself, I'm happy to
do so.
Please let me know if you've experienced anything similar.
Gareth
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
RE: [PATCH] Encoding in TurbineVelocityService
Posted by Ilkka Priha <ex...@nokia.com>.
The parameter parser uses servlet engine's parameters as such and they should be
automatically correct as the request contains a Content-Type header for the
request body specifying also the character set if it's something else than the
default. For POSTs, it should be the same, which was given in the corresponding
response.
If you let the upload service to parse the parameters by having a property
services.UploadService.automatic=true
in TR, then it might not work as the default implementation of the service
doesn't seem to check the req.getCharacterEncoding().
It's also possible to set the form encoding with the ENCTYPE attribute and
(maybe) to append the character set to it (haven't tried this, because I haven't
had problems with encoding of form parameters):
<FORM enctype="application/x-www-form-urlencoded; charset=ISO-8859-7">
...
</FORM>
-- Ilkka
-----Original Message-----
From: Costas Stergiou [mailto:csterg@aias.gr]
Sent: 23. huhtikuuta 2001 9:31
To: turbine-dev@jakarta.apache.org
Subject: Re: [PATCH] Encoding in TurbineVelocityService
Hi,
I think this is very good work and absolutely necessary for Turbine...
I would like to ask if you gave any thoughts to the encoding that
the ParameterParser (BaseValueParser) uses to encode the parameters
sent back by the broswer. I don't think that there is a way
right now to specify the encoding that is used there. There should
be a way to specify the encoding to use for reading the request
parameters, per request. I am not sure how can this be accomplished
since the ParameterParser reads all the parameters from the request
before any action is called.
For example, a hidden parameter could
be used in the html that specifies the encoding (the one that we think
the client is using) in order to read back the parameters. But, how we
could we use this to decide the encoding before actually reading the
parameters in the ParameterParser???
Any thoughts on that. Maybe there is already something that
I am not aware of.
Thanks,
Costas
----- Original Message -----
From: "Ilkka Priha" <ip...@surfeu.fi>
To: "Dev Turbine" <tu...@jakarta.apache.org>
Sent: Saturday, April 21, 2001 7:40 PM
Subject: [PATCH] Encoding in TurbineVelocityService
> Below are results from our template encoding tests:
>
> 1) Velocity 1.0 supports only reading of template files from the disk
using
> the host enviroment's default encoding, which can be changed in OS
specific
> way as stated by Rafal. An encoding that always works with Java files, is
> the unicode '\uxxxx' format. This requires a separate transfomation as no
> one wants to write and maintain such files.
>
> Velocity 1.1 has a new property, input.encoding, with which to specify an
> explicit encoding for reading templates. As only one encoding is
supported,
> the most applicable one is probably UTF-8, which can be used for any
> language. This may also require a separate transformation, if the orginal
> content is produced with some national encoding, like Shift_JIS or Big5.
>
> Velocity has the functionality to use different encodings on a request by
> request basis, but how to utilize this in Turbine is still a bit open.
> However, the Velocity service can be programmed to be compatible with both
> 1.0 and 1.1 by letting it just pass a configuration with appropriate
> properties to Velocity.
>
> 2) The locale specific encoding support, with which to specify the
encoding
> to use for the response to be passed to the client browser, is included in
> the default RunData implementation and seems to work quite nicely. We've
> changed the Velocity service to use this support and tested it with UTF-8,
> ISO-8859-5 and Shift_JIS both with HTML and WML. It's cool to have a
server
> supporting English, Russian and Japanese for web browsers and wap phones
at
> the same time.
>
> The required changes to TurbineVelocityService are below. Now I'd like to
> have comments whether to include these changes in 2.1? Personally, I'd
like
> to include them as they don't alter existing template processing, if
> locale/charset properties are not used, but make turbine to process
> templates correctly, when they are used.
>
> -- Ilkka
>
>
> --- TurbineVelocityService.old Sat Apr 21 12:27:58 2001
> +++ TurbineVelocityService.new Sat Apr 21 12:17:21 2001
> @@ -105,17 +105,7 @@
> implements VelocityService
> {
> /**
> - * Default encoding to use. This is the default for Velocity,
> - * Right now I'm not sure if Turbine considers encoding.
> - * This encoding will be taken from the Velocity service
> - * properties, the defaultEncoding will be used if it
> - * isn't specified.
> - */
> - private String encoding;
> -
> - /**
> - * Default encoding to use. This is the default for Velocity,
> - * Right now I'm not sure if Turbine considers encoding.
> + * Default encoding to use if not specified in the RunData object.
> */
> private String defaultEncoding = "ISO-8859-1";
>
> @@ -252,21 +242,13 @@
> public String handleRequest(Context context, String filename)
> throws TurbineException
> {
> - /*
> - * This is for development.
> - */
> - if (pullModelActive && refreshToolsPerRequest)
> - {
> - TurbinePull.refreshGlobalTools();
> - }
> -
> String results = null;
> ByteArrayOutputStream bytes = null;
>
> try
> {
> bytes = new ByteArrayOutputStream();
> - handleRequest(context, filename, bytes);
> + String encoding = encodeRequest(context, filename, bytes);
> results = bytes.toString(encoding);
> }
> catch(Exception e)
> @@ -303,7 +285,27 @@
> OutputStream output)
> throws TurbineException
> {
> -
> + encodeRequest(context, filename, output);
> + }
> +
> + /**
> + * Process the request and fill in the template with the values
> + * you set in the Context. Apply the encoding from RunData to the
> result.
> + *
> + * @param context A Context.
> + * @param filename A String with the filename of the template.
> + * @param out A OutputStream where we will write the process template
> as
> + * a String.
> + * @return The character encoding applied to the resulting String.
> + *
> + * @throws TurbineException Any exception trown while processing will
> be
> + * wrapped into a TurbineException and rethrown.
> + */
> + private String encodeRequest(Context context,
> + String filename,
> + OutputStream output)
> + throws TurbineException
> + {
> /*
> * This is for development.
> */
> @@ -311,7 +313,26 @@
> {
> TurbinePull.refreshGlobalTools();
> }
> -
> +
> + /*
> + * Get the encoding from the RunData object.
> + */
> + String encoding;
> + Object data = context.get("data");
> + if ((data != null) &&
> + (data instanceof RunData))
> + {
> + encoding = ((RunData) data).getCharSet();
> + if (encoding == null)
> + {
> + encoding = defaultEncoding;
> + }
> + }
> + else
> + {
> + encoding = defaultEncoding;
> + }
> +
> OutputStreamWriter writer = null;
>
> try
> @@ -339,6 +360,8 @@
> */
> }
> }
> +
> + return encoding;
> }
>
> /**
> @@ -370,15 +393,6 @@
> * Get the configuration for this service.
> */
> Configuration configuration = getConfiguration();
> -
> - /*
> - * Set the encoding to use according to the property specified
> - * for in the Velocity service configuration. This property
> - * should probably be melded with the default char set
> - * property already used in the velocity service.
> - */
> - encoding = configuration.getString(
> - "template.encoding", defaultEncoding);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
RE: [PATCH] Encoding in TurbineVelocityService
Posted by Ilkka Priha <ip...@surfeu.fi>.
TurbineVelocityService is now updated to use RunData based encodings if
available.
1) The character encoding (charset) of the response is retrieved with the
RunData.getCharSet() method. The returned value is either the charset set
with the RunData.setCharset(<charset>) method, or the value defined by the
locale.default.charset property, or the charset corresponding to the locale
set with the RunData.setLocale(<locale>) method, or the charset
corresponding to the locale defined by the locale.default.language and
locale.default.country properties, or the default charset of the HTTP 1.1
protocol (ISO-8859-1). Believe it or not, all these are useful when
supporting several languages, markups and access terminals and providing at
the same time good defaults for apps that build on English and ASCII :-)
2) The template encoding of the template files is retrieved with the
RunData.getTemplateEncoding() method. Its value can be set with the
RunData.setTemplateEncoding(<encoding>). If the value is not set, the
encoding defined with the services.VelocityService.input.encoding property
is used. The property based encoding will work by changing the Velocity jar
to version 1.1, thanks to Geir's work. The RunData based encoding is based
on new methods in Velocity and their calls are still commented out. In
addition, there is a caching problem in 1.1 related to template searches
when encoding is not yet known, which Geir has promised to fix as soon as he
will have time.
-- Ilkka
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: [PATCH] Encoding in TurbineVelocityService
Posted by Costas Stergiou <cs...@aias.gr>.
Hi,
I think this is very good work and absolutely necessary for Turbine...
I would like to ask if you gave any thoughts to the encoding that
the ParameterParser (BaseValueParser) uses to encode the parameters
sent back by the broswer. I don't think that there is a way
right now to specify the encoding that is used there. There should
be a way to specify the encoding to use for reading the request
parameters, per request. I am not sure how can this be accomplished
since the ParameterParser reads all the parameters from the request
before any action is called.
For example, a hidden parameter could
be used in the html that specifies the encoding (the one that we think
the client is using) in order to read back the parameters. But, how we
could we use this to decide the encoding before actually reading the
parameters in the ParameterParser???
Any thoughts on that. Maybe there is already something that
I am not aware of.
Thanks,
Costas
----- Original Message -----
From: "Ilkka Priha" <ip...@surfeu.fi>
To: "Dev Turbine" <tu...@jakarta.apache.org>
Sent: Saturday, April 21, 2001 7:40 PM
Subject: [PATCH] Encoding in TurbineVelocityService
> Below are results from our template encoding tests:
>
> 1) Velocity 1.0 supports only reading of template files from the disk
using
> the host enviroment's default encoding, which can be changed in OS
specific
> way as stated by Rafal. An encoding that always works with Java files, is
> the unicode '\uxxxx' format. This requires a separate transfomation as no
> one wants to write and maintain such files.
>
> Velocity 1.1 has a new property, input.encoding, with which to specify an
> explicit encoding for reading templates. As only one encoding is
supported,
> the most applicable one is probably UTF-8, which can be used for any
> language. This may also require a separate transformation, if the orginal
> content is produced with some national encoding, like Shift_JIS or Big5.
>
> Velocity has the functionality to use different encodings on a request by
> request basis, but how to utilize this in Turbine is still a bit open.
> However, the Velocity service can be programmed to be compatible with both
> 1.0 and 1.1 by letting it just pass a configuration with appropriate
> properties to Velocity.
>
> 2) The locale specific encoding support, with which to specify the
encoding
> to use for the response to be passed to the client browser, is included in
> the default RunData implementation and seems to work quite nicely. We've
> changed the Velocity service to use this support and tested it with UTF-8,
> ISO-8859-5 and Shift_JIS both with HTML and WML. It's cool to have a
server
> supporting English, Russian and Japanese for web browsers and wap phones
at
> the same time.
>
> The required changes to TurbineVelocityService are below. Now I'd like to
> have comments whether to include these changes in 2.1? Personally, I'd
like
> to include them as they don't alter existing template processing, if
> locale/charset properties are not used, but make turbine to process
> templates correctly, when they are used.
>
> -- Ilkka
>
>
> --- TurbineVelocityService.old Sat Apr 21 12:27:58 2001
> +++ TurbineVelocityService.new Sat Apr 21 12:17:21 2001
> @@ -105,17 +105,7 @@
> implements VelocityService
> {
> /**
> - * Default encoding to use. This is the default for Velocity,
> - * Right now I'm not sure if Turbine considers encoding.
> - * This encoding will be taken from the Velocity service
> - * properties, the defaultEncoding will be used if it
> - * isn't specified.
> - */
> - private String encoding;
> -
> - /**
> - * Default encoding to use. This is the default for Velocity,
> - * Right now I'm not sure if Turbine considers encoding.
> + * Default encoding to use if not specified in the RunData object.
> */
> private String defaultEncoding = "ISO-8859-1";
>
> @@ -252,21 +242,13 @@
> public String handleRequest(Context context, String filename)
> throws TurbineException
> {
> - /*
> - * This is for development.
> - */
> - if (pullModelActive && refreshToolsPerRequest)
> - {
> - TurbinePull.refreshGlobalTools();
> - }
> -
> String results = null;
> ByteArrayOutputStream bytes = null;
>
> try
> {
> bytes = new ByteArrayOutputStream();
> - handleRequest(context, filename, bytes);
> + String encoding = encodeRequest(context, filename, bytes);
> results = bytes.toString(encoding);
> }
> catch(Exception e)
> @@ -303,7 +285,27 @@
> OutputStream output)
> throws TurbineException
> {
> -
> + encodeRequest(context, filename, output);
> + }
> +
> + /**
> + * Process the request and fill in the template with the values
> + * you set in the Context. Apply the encoding from RunData to the
> result.
> + *
> + * @param context A Context.
> + * @param filename A String with the filename of the template.
> + * @param out A OutputStream where we will write the process template
> as
> + * a String.
> + * @return The character encoding applied to the resulting String.
> + *
> + * @throws TurbineException Any exception trown while processing will
> be
> + * wrapped into a TurbineException and rethrown.
> + */
> + private String encodeRequest(Context context,
> + String filename,
> + OutputStream output)
> + throws TurbineException
> + {
> /*
> * This is for development.
> */
> @@ -311,7 +313,26 @@
> {
> TurbinePull.refreshGlobalTools();
> }
> -
> +
> + /*
> + * Get the encoding from the RunData object.
> + */
> + String encoding;
> + Object data = context.get("data");
> + if ((data != null) &&
> + (data instanceof RunData))
> + {
> + encoding = ((RunData) data).getCharSet();
> + if (encoding == null)
> + {
> + encoding = defaultEncoding;
> + }
> + }
> + else
> + {
> + encoding = defaultEncoding;
> + }
> +
> OutputStreamWriter writer = null;
>
> try
> @@ -339,6 +360,8 @@
> */
> }
> }
> +
> + return encoding;
> }
>
> /**
> @@ -370,15 +393,6 @@
> * Get the configuration for this service.
> */
> Configuration configuration = getConfiguration();
> -
> - /*
> - * Set the encoding to use according to the property specified
> - * for in the Velocity service configuration. This property
> - * should probably be melded with the default char set
> - * property already used in the velocity service.
> - */
> - encoding = configuration.getString(
> - "template.encoding", defaultEncoding);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org