You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Yuval Schwartz <yu...@gmail.com> on 2016/03/08 09:14:00 UTC

Mapping servlet to non English url pattern

Tomcat version: 8.0.22
Jdk: 1.8.0_05
Server: Amazon Linux

Hello,

I want to map my servlet to a Hebrew url pattern.

I tried placing the hebrew url pattern both in the "@webservlet" annotation
(urlpatterns attribute) and in the the web.xml file. In both cases it
doesn't work, it's as if there's nothing mapped to the url specified.

I though to specify the URIEncoding parameter of the connector but saw that
this defaults to "utf-8" in tomcat 8.

Any suggestions on how I can get this working?

Thank you.

Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
On Wed, Mar 9, 2016 at 5:38 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> Yuval,
>
> On 3/8/16 4:04 PM, Yuval Schwartz wrote:
> > @WebServlet(name="SomeServlet", urlPatterns={"/help/why-no-work",
> > "/iw/help/למה-לא-עובד",
> > "/iw/help/%D7%9C%D7%9E%D7%94-%D7%9C%D7%90-%D7%A2%D7%95%D7%91%D7%93"}
> > (the last pattern is the same as the second to last, just encoded)
>
> I think that last pattern will not be useful, because Tomcat should be
> doing the encoding internally. For example, if you wanted to map a
> servlet to "/foo bar" you wouldn't have to URL-encode it like /foo%20bar
> in the XML file. But I haven't actually tried it.
>
> (from your other post):
>
> On 3/8/16 5:35 PM, Yuval Schwartz wrote:
> > I did this and it worked:
> > The english patterns show up fine, as expected.
> > The hebrew pattern shows up as a bunch of question marks (eg:
> > ????-?????-????)
> > The URLEncoded pattern shows up as wierd symbols (eg: diamond shape,
> > tm symbol).
>
> Hmm, that could certainly be a problem with the tool itself (Netbeans?).
> Can you try running with jconsole just to have a (potentially) clean
> environment?
>

Hey, can you clarify a bit? What do you mean "try running with jconsole"?
Run what? As I understand it, JConsole is for monitoring.


>
> The encoded pattern showing up as weird symbols sounds .. odd as well.
> Actually, everything about this sounds weird.
>

> On 3/9/16 4:38 AM, Yuval Schwartz wrote:
> > Are you suggesting I convert all of my source files to UTF-8? Will
> > all new files that are created now be in UTF-8 at least? Because I
> > just created a new servlet for testing purposes (after the
> > -J-Dfile.encoding property was added) and hebrew urls still aren't
> > found.
>
> You definitely don't need to convert your files to UTF-8, but you might
> instead want to use the encoding-proof Unicode escapes instead of the
> raw Hebrew in your source files.
>
> You can use native2ascii to do this for you:
>
> input.txt
> /iw/help/למה-לא-עובד
>
> $ native2ascii -encoding utf8 input.txt
> /iw/help/\u05dc\u05de\u05d4-\u05dc\u05d0-\u05e2\u05d5\u05d1\u05d3
>
> So those are the \u Unicode escapes that you should use in your code.
> Try using those and rebuilding to see if it improves anything.
>

This doesn't work.



>
> -chris
>

Thank you

>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
Christopher,

On Wed, Mar 9, 2016 at 5:38 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> Yuval,
>
> On 3/8/16 4:04 PM, Yuval Schwartz wrote:
> > @WebServlet(name="SomeServlet", urlPatterns={"/help/why-no-work",
> > "/iw/help/למה-לא-עובד",
> > "/iw/help/%D7%9C%D7%9E%D7%94-%D7%9C%D7%90-%D7%A2%D7%95%D7%91%D7%93"}
> > (the last pattern is the same as the second to last, just encoded)
>
> I think that last pattern will not be useful, because Tomcat should be
> doing the encoding internally. For example, if you wanted to map a
> servlet to "/foo bar" you wouldn't have to URL-encode it like /foo%20bar
> in the XML file. But I haven't actually tried it.
>
> (from your other post):
>
> On 3/8/16 5:35 PM, Yuval Schwartz wrote:
> > I did this and it worked:
> > The english patterns show up fine, as expected.
> > The hebrew pattern shows up as a bunch of question marks (eg:
> > ????-?????-????)
> > The URLEncoded pattern shows up as wierd symbols (eg: diamond shape,
> > tm symbol).
>
> Hmm, that could certainly be a problem with the tool itself (Netbeans?).
> Can you try running with jconsole just to have a (potentially) clean
> environment?
>
> The encoded pattern showing up as weird symbols sounds .. odd as well.
> Actually, everything about this sounds weird.
>

Do you say this because this is usually something that is straightforward
and simple that doesn't have many issues?


>
> On 3/9/16 4:38 AM, Yuval Schwartz wrote:
> > Are you suggesting I convert all of my source files to UTF-8? Will
> > all new files that are created now be in UTF-8 at least? Because I
> > just created a new servlet for testing purposes (after the
> > -J-Dfile.encoding property was added) and hebrew urls still aren't
> > found.
>
> You definitely don't need to convert your files to UTF-8, but you might
> instead want to use the encoding-proof Unicode escapes instead of the
> raw Hebrew in your source files.
>
> You can use native2ascii to do this for you:
>
> input.txt
> /iw/help/למה-לא-עובד
>
> $ native2ascii -encoding utf8 input.txt
> /iw/help/\u05dc\u05de\u05d4-\u05dc\u05d0-\u05e2\u05d5\u05d1\u05d3
>
> So those are the \u Unicode escapes that you should use in your code.
> Try using those and rebuilding to see if it improves anything.
>
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Mapping servlet to non English url pattern

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Yuval,

On 3/8/16 4:04 PM, Yuval Schwartz wrote:
> @WebServlet(name="SomeServlet", urlPatterns={"/help/why-no-work",
> "/iw/help/למה-לא-עובד",
> "/iw/help/%D7%9C%D7%9E%D7%94-%D7%9C%D7%90-%D7%A2%D7%95%D7%91%D7%93"}
> (the last pattern is the same as the second to last, just encoded)

I think that last pattern will not be useful, because Tomcat should be
doing the encoding internally. For example, if you wanted to map a
servlet to "/foo bar" you wouldn't have to URL-encode it like /foo%20bar
in the XML file. But I haven't actually tried it.

(from your other post):

On 3/8/16 5:35 PM, Yuval Schwartz wrote:
> I did this and it worked:
> The english patterns show up fine, as expected.
> The hebrew pattern shows up as a bunch of question marks (eg:
> ????-?????-????)
> The URLEncoded pattern shows up as wierd symbols (eg: diamond shape,
> tm symbol).

Hmm, that could certainly be a problem with the tool itself (Netbeans?).
Can you try running with jconsole just to have a (potentially) clean
environment?

The encoded pattern showing up as weird symbols sounds .. odd as well.
Actually, everything about this sounds weird.

On 3/9/16 4:38 AM, Yuval Schwartz wrote:
> Are you suggesting I convert all of my source files to UTF-8? Will
> all new files that are created now be in UTF-8 at least? Because I 
> just created a new servlet for testing purposes (after the 
> -J-Dfile.encoding property was added) and hebrew urls still aren't
> found.

You definitely don't need to convert your files to UTF-8, but you might
instead want to use the encoding-proof Unicode escapes instead of the
raw Hebrew in your source files.

You can use native2ascii to do this for you:

input.txt
/iw/help/למה-לא-עובד

$ native2ascii -encoding utf8 input.txt
/iw/help/\u05dc\u05de\u05d4-\u05dc\u05d0-\u05e2\u05d5\u05d1\u05d3

So those are the \u Unicode escapes that you should use in your code.
Try using those and rebuilding to see if it improves anything.

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
On Tue, Mar 8, 2016 at 10:55 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Yuval,
>
> On 3/8/16 3:47 PM, Yuval Schwartz wrote:
> > On Tue, Mar 8, 2016 at 10:20 PM, Christopher Schultz <
> > chris@christopherschultz.net> wrote:
> >
> > Yuval,
> >
> > On 3/8/16 12:38 PM, Yuval Schwartz wrote:
> >>>> Hello Christopher, thanks, responses below.
> >>>>
> >>>> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
> >>>> chris@christopherschultz.net> wrote:
> >>>>
> >>>> Yuval,
> >>>>
> >>>> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
> >>>>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon
> >>>>>>> Linux
> >>>>>>>
> >>>>>>> Hello,
> >>>>>>>
> >>>>>>> I want to map my servlet to a Hebrew url pattern.
> >>>>
> >>>> Hmm.
> >>>>
> >>>>>>> I tried placing the hebrew url pattern both in the
> >>>>>>> "@webservlet" annotation (urlpatterns attribute) and in
> >>>>>>> the the web.xml file. In both cases it doesn't work,
> >>>>>>> it's as if there's nothing mapped to the url
> >>>>>>> specified.
> >>>>>>>
> >>>>>>> I though to specify the URIEncoding parameter of the
> >>>>>>> connector but saw that this defaults to "utf-8" in
> >>>>>>> tomcat 8.
> >>>>
> >>>> Yes, it does.
> >>>>
> >>>> So you are trying to set the url-pattern for a servlet
> >>>> mapping?
> >>>>
> >>>> When you do it -- either using @WebServlet or
> >>>> <servlet-mapping> -- can you connect via JMX to observe the
> >>>> pattern that's been read into the configuration? First, I'd
> >>>> want to make sure that the Hebrew characters haven't been
> >>>> destroyed by the loading process of the XML file or by the
> >>>> compiler, or even by Tomcat.
> >>>>
> >>>>
> >>>>> Can you give me some direction on how I would do this?
> >>>>> Maybe a little more detail on jmx? There could be
> >>>>> encoding/decoding going on in the browser (firefox) and in
> >>>>> all the elements you mentioned on the server side. Any way
> >>>>> to see the final String that the server is using to match
> >>>>> the Url pattern?
> >
> > Yeah, that's why I was suggesting using JMX, since Tomcat exposes
> > all the configuration through it.
> >
> > Launch Tomcat, then fire-up jconsole (or VisualVM, or any other
> > tool that contains a JMX client... both jconsole and VisualVM
> > require that you go to the "plug-ins" configuration and install an
> > easy-to-find-and-install plug-in for JMX) on the same machine
> > (it's easiest this way).
> >
> > (I just checked, and VisualVM calls the plug-in
> > "VisualVM-MBeans".)visualvisual
> >
> > Then, connect to the Tomcat instance and go to the BMeans tab.
> >
> > You'll find your servlet under
> > /Catalina/Servlet/host/context/[servlet]. ..
> >
> >
> > Aw, crap. The mappings themselves aren't actually published via
> > JMX. Hmm .
> >
> >>>>> I've done a lot of guessing and checking. For example, I
> >>>>> used the URLEncoder to get the encoded form of my urls and
> >>>>> put that in the url pattern.
> >
> > Good. So you have some set of Unicode escapes like \u0fe64 or
> > whatever in the url-pattern string in your annotation?
> >
> >
> >> No, I don't have any unicode escapes. I have (for the purpose of
> >> testing) two strings, one is the string with the utf-8
> >> characters, the other is an encoded form of the url (which is
> >> encoded into a series of "%" followed by two English letters). Do
> >> you recommend having something else here?
>
> Can you copy/paste your @WebServlet annotation into your next post? I
> think that will clear things up.
>

@WebServlet(name="SomeServlet", urlPatterns={"/help/why-no-work",
"/iw/help/למה-לא-עובד",
"/iw/help/%D7%9C%D7%9E%D7%94-%D7%9C%D7%90-%D7%A2%D7%95%D7%91%D7%93"}
(the last pattern is the same as the second to last, just encoded)

I will try the other stuff suggested and get back to you.


>
> >> Some more info: I placed a filter on pattern "/*". When my
> >> request with the UTF-8 url comes in, I call
> >> httpRequest.getServletPath() and httpRequest.getRequestURI(). As
> >> expected, I get the UTF-8 version of the servlet path (ie:
> >> decoded) and the ASCII request URI (ie: encoded) respectively.
>
> Good idea. So, does your application get what you expected in the
> String servlet path?
>
> >> This means that the request is reaching my server. It's the next
> >> step, the step where the servlet path is mapped to my specified
> >> url pattern, that I want to explore. But I don't know how to
> >> explore this. Where can I control how the url pattern is matched
> >> with the incoming url?
>
> You can't, other than following the rules of the servlet spec. Since
> you can get a Filter in the mix, try mapping the filter to "/smaller"
> where "smaller" is something narrower than "*" that gets you closer to
> what you were trying to accomplish. For instance, if you are trying to
> map to /עברית, then try mapping your filter to /ת* or something like
> that. (I have no idea what the left-to-right rules are for
> string-matching, etc. since Hebrew should be right-to-left, but
> prefix-matching is usually written in a left-to-right fashion).
>
> >> Although I can only conceive two options for how the incoming url
> >> is matched with the url pattern and I've tried both (either the
> >> UTF-8 version of the request url is matched against the pattern
> >> or the encoded version is matched against the pattern).
>
> Tomcat is doing a left-to-right pattern-match, character-by-character,
> as long as there wasn't an exact-match that was found (which would
> have been done roughly using String.equals, though in Tomcat it's
> working with character buffers and not String values).
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iEYEARECAAYFAlbfPD0ACgkQ9CaO5/Lv0PCD7QCdE4wcSoUzCI3nUcemqUh7cNbb
> hMYAn3X9P5eHIiNbDxunlRwLfgLViD0t
> =8itk
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Mapping servlet to non English url pattern

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yuval,

On 3/8/16 3:47 PM, Yuval Schwartz wrote:
> On Tue, Mar 8, 2016 at 10:20 PM, Christopher Schultz < 
> chris@christopherschultz.net> wrote:
> 
> Yuval,
> 
> On 3/8/16 12:38 PM, Yuval Schwartz wrote:
>>>> Hello Christopher, thanks, responses below.
>>>> 
>>>> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz < 
>>>> chris@christopherschultz.net> wrote:
>>>> 
>>>> Yuval,
>>>> 
>>>> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
>>>>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon
>>>>>>> Linux
>>>>>>> 
>>>>>>> Hello,
>>>>>>> 
>>>>>>> I want to map my servlet to a Hebrew url pattern.
>>>> 
>>>> Hmm.
>>>> 
>>>>>>> I tried placing the hebrew url pattern both in the 
>>>>>>> "@webservlet" annotation (urlpatterns attribute) and in
>>>>>>> the the web.xml file. In both cases it doesn't work,
>>>>>>> it's as if there's nothing mapped to the url
>>>>>>> specified.
>>>>>>> 
>>>>>>> I though to specify the URIEncoding parameter of the 
>>>>>>> connector but saw that this defaults to "utf-8" in
>>>>>>> tomcat 8.
>>>> 
>>>> Yes, it does.
>>>> 
>>>> So you are trying to set the url-pattern for a servlet
>>>> mapping?
>>>> 
>>>> When you do it -- either using @WebServlet or
>>>> <servlet-mapping> -- can you connect via JMX to observe the
>>>> pattern that's been read into the configuration? First, I'd
>>>> want to make sure that the Hebrew characters haven't been
>>>> destroyed by the loading process of the XML file or by the
>>>> compiler, or even by Tomcat.
>>>> 
>>>> 
>>>>> Can you give me some direction on how I would do this?
>>>>> Maybe a little more detail on jmx? There could be
>>>>> encoding/decoding going on in the browser (firefox) and in
>>>>> all the elements you mentioned on the server side. Any way
>>>>> to see the final String that the server is using to match
>>>>> the Url pattern?
> 
> Yeah, that's why I was suggesting using JMX, since Tomcat exposes
> all the configuration through it.
> 
> Launch Tomcat, then fire-up jconsole (or VisualVM, or any other
> tool that contains a JMX client... both jconsole and VisualVM
> require that you go to the "plug-ins" configuration and install an 
> easy-to-find-and-install plug-in for JMX) on the same machine
> (it's easiest this way).
> 
> (I just checked, and VisualVM calls the plug-in 
> "VisualVM-MBeans".)visualvisual
> 
> Then, connect to the Tomcat instance and go to the BMeans tab.
> 
> You'll find your servlet under
> /Catalina/Servlet/host/context/[servlet]. ..
> 
> 
> Aw, crap. The mappings themselves aren't actually published via
> JMX. Hmm .
> 
>>>>> I've done a lot of guessing and checking. For example, I
>>>>> used the URLEncoder to get the encoded form of my urls and
>>>>> put that in the url pattern.
> 
> Good. So you have some set of Unicode escapes like \u0fe64 or
> whatever in the url-pattern string in your annotation?
> 
> 
>> No, I don't have any unicode escapes. I have (for the purpose of
>> testing) two strings, one is the string with the utf-8
>> characters, the other is an encoded form of the url (which is
>> encoded into a series of "%" followed by two English letters). Do
>> you recommend having something else here?

Can you copy/paste your @WebServlet annotation into your next post? I
think that will clear things up.

>> Some more info: I placed a filter on pattern "/*". When my
>> request with the UTF-8 url comes in, I call 
>> httpRequest.getServletPath() and httpRequest.getRequestURI(). As
>> expected, I get the UTF-8 version of the servlet path (ie:
>> decoded) and the ASCII request URI (ie: encoded) respectively.

Good idea. So, does your application get what you expected in the
String servlet path?

>> This means that the request is reaching my server. It's the next
>> step, the step where the servlet path is mapped to my specified
>> url pattern, that I want to explore. But I don't know how to
>> explore this. Where can I control how the url pattern is matched
>> with the incoming url?

You can't, other than following the rules of the servlet spec. Since
you can get a Filter in the mix, try mapping the filter to "/smaller"
where "smaller" is something narrower than "*" that gets you closer to
what you were trying to accomplish. For instance, if you are trying to
map to /עברית, then try mapping your filter to /ת* or something like
that. (I have no idea what the left-to-right rules are for
string-matching, etc. since Hebrew should be right-to-left, but
prefix-matching is usually written in a left-to-right fashion).

>> Although I can only conceive two options for how the incoming url
>> is matched with the url pattern and I've tried both (either the
>> UTF-8 version of the request url is matched against the pattern
>> or the encoded version is matched against the pattern).

Tomcat is doing a left-to-right pattern-match, character-by-character,
as long as there wasn't an exact-match that was found (which would
have been done roughly using String.equals, though in Tomcat it's
working with character buffers and not String values).

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlbfPD0ACgkQ9CaO5/Lv0PCD7QCdE4wcSoUzCI3nUcemqUh7cNbb
hMYAn3X9P5eHIiNbDxunlRwLfgLViD0t
=8itk
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
Thanks again, see below...

On Tue, Mar 8, 2016 at 10:20 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Yuval,
>
> On 3/8/16 12:38 PM, Yuval Schwartz wrote:
> > Hello Christopher, thanks, responses below.
> >
> > On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
> > chris@christopherschultz.net> wrote:
> >
> > Yuval,
> >
> > On 3/8/16 3:14 AM, Yuval Schwartz wrote:
> >>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
> >>>>
> >>>> Hello,
> >>>>
> >>>> I want to map my servlet to a Hebrew url pattern.
> >
> > Hmm.
> >
> >>>> I tried placing the hebrew url pattern both in the
> >>>> "@webservlet" annotation (urlpatterns attribute) and in the
> >>>> the web.xml file. In both cases it doesn't work, it's as if
> >>>> there's nothing mapped to the url specified.
> >>>>
> >>>> I though to specify the URIEncoding parameter of the
> >>>> connector but saw that this defaults to "utf-8" in tomcat 8.
> >
> > Yes, it does.
> >
> > So you are trying to set the url-pattern for a servlet mapping?
> >
> > When you do it -- either using @WebServlet or <servlet-mapping> --
> > can you connect via JMX to observe the pattern that's been read
> > into the configuration? First, I'd want to make sure that the
> > Hebrew characters haven't been destroyed by the loading process of
> > the XML file or by the compiler, or even by Tomcat.
> >
> >
> >> Can you give me some direction on how I would do this? Maybe a
> >> little more detail on jmx? There could be encoding/decoding going
> >> on in the browser (firefox) and in all the elements you mentioned
> >> on the server side. Any way to see the final String that the
> >> server is using to match the Url pattern?
>
> Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
> the configuration through it.
>
> Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
> that contains a JMX client... both jconsole and VisualVM require that
> you go to the "plug-ins" configuration and install an
> easy-to-find-and-install plug-in for JMX) on the same machine (it's
> easiest this way).
>
> (I just checked, and VisualVM calls the plug-in
> "VisualVM-MBeans".)visualvisual
>
> Then, connect to the Tomcat instance and go to the BMeans tab.
>
> You'll find your servlet under /Catalina/Servlet/host/context/[servlet].
> ..
>
>
> Aw, crap. The mappings themselves aren't actually published via JMX. Hmm
> .
>
> >> I've done a lot of guessing and checking. For example, I used
> >> the URLEncoder to get the encoded form of my urls and put that in
> >> the url pattern.
>
> Good. So you have some set of Unicode escapes like \u0fe64 or whatever
> in the url-pattern string in your annotation?
>

No, I don't have any unicode escapes. I have (for the purpose of testing)
two strings, one is the string with the utf-8 characters, the other is an
encoded form of the url (which is encoded into a series of "%" followed by
two English letters).
Do you recommend having something else here?

Some more info:
I placed a filter on pattern "/*".
When my request with the UTF-8 url comes in, I call
httpRequest.getServletPath() and httpRequest.getRequestURI().
As expected, I get the UTF-8 version of the servlet path (ie: decoded) and
the ASCII request URI (ie: encoded) respectively.

This means that the request is reaching my server. It's the next step, the
step where the servlet path is mapped to my specified url pattern, that I
want to explore. But I don't know how to explore this. Where can I control
how the url pattern is matched with the incoming url?
Although I can only conceive two options for how the incoming url is
matched with the url pattern and I've tried both (either the UTF-8 version
of the request url is matched against the pattern or the encoded version is
matched against the pattern).


>
> >> Therefore, the xml loading process/compiler/tomcat/netbeans
> >> shouldn't do anything to change it (in the case where I encode
> >> the pattern), but the servlet still isn't found.
>
> Well, if you use annotations, the XML shouldn't be a problem at all,
> of course. But you said you were having problems using the
> web.xml-based configuration, too, right?
>
> When you type the URL into your browser, are you just typing the
> Hebrew right into the browser, or have you UTF/URL-escaped it first
> and then copy/pasted it into the browser (or, better yet, provide a
> link from another page that isn't giving you any problems).
>

I load the url into the href attribute of an "a" tag.
I have tried placing the regular hebrew into the attribute as well as
placing the encoded form of the hebrew
(ie: /package/[some hebrew] & /package/%D7%99%D7... respectively).
The latter is how wikipedia does it, inspect the elements to see for
yourself (
https://he.wikipedia.org/wiki/%D7%9E%D7%9C%D7%97%D7%9E%D7%AA_%D7%94%D7%A2%D7%A6%D7%9E%D7%90%D7%95%D7%AA)
(...the browser automatically encodes the link when I copy it :)


>
> You might want to make sure that Tomcat is delivering all responses in
> UTF-8, so that the browser (hopefully) decides to send the URL for the
> *next* page in UTF-8 instead of some weird ISO-8859-1 mess.
>
>
I place a filter that sets the response encoding to UTF-8, doesn't help.

Thanks a lot for your help and time.


> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iEYEARECAAYFAlbfNBIACgkQ9CaO5/Lv0PAEswCcD9K3iwDplOASR81WtIMQZVFb
> 77YAnisxPAcn8/vuAU1PNDQgnvGuLVlo
> =LmWf
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

On Tue, Mar 8, 2016 at 10:20 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Yuval,
>
> On 3/8/16 12:38 PM, Yuval Schwartz wrote:
> > Hello Christopher, thanks, responses below.
> >
> > On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
> > chris@christopherschultz.net> wrote:
> >
> > Yuval,
> >
> > On 3/8/16 3:14 AM, Yuval Schwartz wrote:
> >>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
> >>>>
> >>>> Hello,
> >>>>
> >>>> I want to map my servlet to a Hebrew url pattern.
> >
> > Hmm.
> >
> >>>> I tried placing the hebrew url pattern both in the
> >>>> "@webservlet" annotation (urlpatterns attribute) and in the
> >>>> the web.xml file. In both cases it doesn't work, it's as if
> >>>> there's nothing mapped to the url specified.
> >>>>
> >>>> I though to specify the URIEncoding parameter of the
> >>>> connector but saw that this defaults to "utf-8" in tomcat 8.
> >
> > Yes, it does.
> >
> > So you are trying to set the url-pattern for a servlet mapping?
> >
> > When you do it -- either using @WebServlet or <servlet-mapping> --
> > can you connect via JMX to observe the pattern that's been read
> > into the configuration? First, I'd want to make sure that the
> > Hebrew characters haven't been destroyed by the loading process of
> > the XML file or by the compiler, or even by Tomcat.
> >
> >
> >> Can you give me some direction on how I would do this? Maybe a
> >> little more detail on jmx? There could be encoding/decoding going
> >> on in the browser (firefox) and in all the elements you mentioned
> >> on the server side. Any way to see the final String that the
> >> server is using to match the Url pattern?
>
> Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
> the configuration through it.
>
> Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
> that contains a JMX client... both jconsole and VisualVM require that
> you go to the "plug-ins" configuration and install an
> easy-to-find-and-install plug-in for JMX) on the same machine (it's
> easiest this way).
>
> (I just checked, and VisualVM calls the plug-in
> "VisualVM-MBeans".)visualvisual
>
> Then, connect to the Tomcat instance and go to the BMeans tab.
>
> You'll find your servlet under /Catalina/Servlet/host/context/[servlet].
> ..
>
>
> Aw, crap. The mappings themselves aren't actually published via JMX. Hmm
> .
>
> >> I've done a lot of guessing and checking. For example, I used
> >> the URLEncoder to get the encoded form of my urls and put that in
> >> the url pattern.
>
> Good. So you have some set of Unicode escapes like \u0fe64 or whatever
> in the url-pattern string in your annotation?
>
> >> Therefore, the xml loading process/compiler/tomcat/netbeans
> >> shouldn't do anything to change it (in the case where I encode
> >> the pattern), but the servlet still isn't found.
>
> Well, if you use annotations, the XML shouldn't be a problem at all,
> of course. But you said you were having problems using the
> web.xml-based configuration, too, right?
>
> When you type the URL into your browser, are you just typing the
> Hebrew right into the browser, or have you UTF/URL-escaped it first
> and then copy/pasted it into the browser (or, better yet, provide a
> link from another page that isn't giving you any problems).
>
> You might want to make sure that Tomcat is delivering all responses in
> UTF-8, so that the browser (hopefully) decides to send the URL for the
> *next* page in UTF-8 instead of some weird ISO-8859-1 mess.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iEYEARECAAYFAlbfNBIACgkQ9CaO5/Lv0PAEswCcD9K3iwDplOASR81WtIMQZVFb
> 77YAnisxPAcn8/vuAU1PNDQgnvGuLVlo
> =LmWf
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
Sorry, I should also say, I specified in the beginning that I am using
Amazon linux AMI but that is my production server. Right now, I'm testing
in my development environment and this is on a windows system. All the rest
of the versions I mentioned are the same. Could it be something with the
Windows system that is not handling utf8 correctly?

On Wed, Mar 9, 2016 at 12:35 AM, Yuval Schwartz <yu...@gmail.com>
wrote:

>
>
> On Tue, Mar 8, 2016 at 10:53 PM, Mark Thomas <ma...@apache.org> wrote:
>
>> On 08/03/2016 20:20, Christopher Schultz wrote:
>> > Yuval,
>> >
>> > On 3/8/16 12:38 PM, Yuval Schwartz wrote:
>> >> Hello Christopher, thanks, responses below.
>> >
>> >> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
>> >> chris@christopherschultz.net> wrote:
>> >
>> >> Yuval,
>> >
>> >> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
>> >>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
>> >>>>>
>> >>>>> Hello,
>> >>>>>
>> >>>>> I want to map my servlet to a Hebrew url pattern.
>> >
>> >> Hmm.
>> >
>> >>>>> I tried placing the hebrew url pattern both in the
>> >>>>> "@webservlet" annotation (urlpatterns attribute) and in the
>> >>>>> the web.xml file. In both cases it doesn't work, it's as if
>> >>>>> there's nothing mapped to the url specified.
>> >>>>>
>> >>>>> I though to specify the URIEncoding parameter of the
>> >>>>> connector but saw that this defaults to "utf-8" in tomcat 8.
>> >
>> >> Yes, it does.
>> >
>> >> So you are trying to set the url-pattern for a servlet mapping?
>> >
>> >> When you do it -- either using @WebServlet or <servlet-mapping> --
>> >> can you connect via JMX to observe the pattern that's been read
>> >> into the configuration? First, I'd want to make sure that the
>> >> Hebrew characters haven't been destroyed by the loading process of
>> >> the XML file or by the compiler, or even by Tomcat.
>> >
>> >
>> >>> Can you give me some direction on how I would do this? Maybe a
>> >>> little more detail on jmx? There could be encoding/decoding going
>> >>> on in the browser (firefox) and in all the elements you mentioned
>> >>> on the server side. Any way to see the final String that the
>> >>> server is using to match the Url pattern?
>> >
>> > Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
>> > the configuration through it.
>> >
>> > Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
>> > that contains a JMX client... both jconsole and VisualVM require that
>> > you go to the "plug-ins" configuration and install an
>> > easy-to-find-and-install plug-in for JMX) on the same machine (it's
>> > easiest this way).
>> >
>> > (I just checked, and VisualVM calls the plug-in
>> > "VisualVM-MBeans".)visualvisual
>> >
>> > Then, connect to the Tomcat instance and go to the BMeans tab.
>> >
>> > You'll find your servlet under /Catalina/Servlet/host/context/[servlet].
>> > ..
>> >
>> >
>> > Aw, crap. The mappings themselves aren't actually published via JMX. Hmm
>>
>> Yes they are.
>>
>> You need to look at the operations. findMappings() will list them.
>>
>
> I did this and it worked:
> The english patterns show up fine, as expected.
> The hebrew pattern shows up as a bunch of question marks (eg:
> ????-?????-????)
> The URLEncoded pattern shows up as wierd symbols (eg: diamond shape, tm
> symbol).
>
> Could this be something in my IDE (Netbeans) settings? The logs for
> example, display hebrew characters as question marks. Although my project
> encoding is set as UTF-8.
>
> Thanks.
>
>
>
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
On Wed, Mar 9, 2016 at 7:46 PM, Mark Eggers <it...@yahoo.com.invalid>
wrote:

> Yuval,
>
> Notes are inline (I hope). This is quickly becoming a NetBeans question.
>
> On 3/9/2016 1:38 AM, Yuval Schwartz wrote:
> > Thanks Mark, follow up questions below:
> >
> > On Wed, Mar 9, 2016 at 1:26 AM, Mark Eggers
> <it...@yahoo.com.invalid>
> > wrote:
> >
> >> Yuval,
> >>
> >> On 3/8/2016 2:35 PM, Yuval Schwartz wrote:
> >>> On Tue, Mar 8, 2016 at 10:53 PM, Mark Thomas <ma...@apache.org> wrote:
> >>>
> >>>> On 08/03/2016 20:20, Christopher Schultz wrote:
> >>>>> Yuval,
> >>>>>
> >>>>> On 3/8/16 12:38 PM, Yuval Schwartz wrote:
> >>>>>> Hello Christopher, thanks, responses below.
> >>>>>
> >>>>>> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
> >>>>>> chris@christopherschultz.net> wrote:
> >>>>>
> >>>>>> Yuval,
> >>>>>
> >>>>>> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
> >>>>>>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
> >>>>>>>>>
> >>>>>>>>> Hello,
> >>>>>>>>>
> >>>>>>>>> I want to map my servlet to a Hebrew url pattern.
> >>>>>
> >>>>>> Hmm.
> >>>>>
> >>>>>>>>> I tried placing the hebrew url pattern both in the
> >>>>>>>>> "@webservlet" annotation (urlpatterns attribute) and in the
> >>>>>>>>> the web.xml file. In both cases it doesn't work, it's as if
> >>>>>>>>> there's nothing mapped to the url specified.
> >>>>>>>>>
> >>>>>>>>> I though to specify the URIEncoding parameter of the
> >>>>>>>>> connector but saw that this defaults to "utf-8" in tomcat 8.
> >>>>>
> >>>>>> Yes, it does.
> >>>>>
> >>>>>> So you are trying to set the url-pattern for a servlet mapping?
> >>>>>
> >>>>>> When you do it -- either using @WebServlet or <servlet-mapping> --
> >>>>>> can you connect via JMX to observe the pattern that's been read
> >>>>>> into the configuration? First, I'd want to make sure that the
> >>>>>> Hebrew characters haven't been destroyed by the loading process of
> >>>>>> the XML file or by the compiler, or even by Tomcat.
> >>>>>
> >>>>>
> >>>>>>> Can you give me some direction on how I would do this? Maybe a
> >>>>>>> little more detail on jmx? There could be encoding/decoding going
> >>>>>>> on in the browser (firefox) and in all the elements you mentioned
> >>>>>>> on the server side. Any way to see the final String that the
> >>>>>>> server is using to match the Url pattern?
> >>>>>
> >>>>> Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
> >>>>> the configuration through it.
> >>>>>
> >>>>> Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
> >>>>> that contains a JMX client... both jconsole and VisualVM require that
> >>>>> you go to the "plug-ins" configuration and install an
> >>>>> easy-to-find-and-install plug-in for JMX) on the same machine (it's
> >>>>> easiest this way).
> >>>>>
> >>>>> (I just checked, and VisualVM calls the plug-in
> >>>>> "VisualVM-MBeans".)visualvisual
> >>>>>
> >>>>> Then, connect to the Tomcat instance and go to the BMeans tab.
> >>>>>
> >>>>> You'll find your servlet under
> >> /Catalina/Servlet/host/context/[servlet].
> >>>>> ..
> >>>>>
> >>>>>
> >>>>> Aw, crap. The mappings themselves aren't actually published via JMX.
> >> Hmm
> >>>>
> >>>> Yes they are.
> >>>>
> >>>> You need to look at the operations. findMappings() will list them.
> >>>>
> >>>
> >>> I did this and it worked:
> >>> The english patterns show up fine, as expected.
> >>> The hebrew pattern shows up as a bunch of question marks (eg:
> >>> ????-?????-????)
> >>> The URLEncoded pattern shows up as wierd symbols (eg: diamond shape, tm
> >>> symbol).
> >>>
> >>> Could this be something in my IDE (Netbeans) settings? The logs for
> >>> example, display hebrew characters as question marks. Although my
> project
> >>> encoding is set as UTF-8.
> >>>
> >>> Thanks.
> >>>
> >>>
> >>>
> >>>>
> >>>> Mark
> >>
> >> Are you developing on Windows? (ah, you are)
> >>
> >> If so, could you check how you launch NetBeans? My netbeans.conf file
> >> contains this on the netbeans_default_options line:
> >>
> >> -J-Dfile.encoding=UTF-8
> >>
> >
> > I tried this, still doesn't fix the issue (Although a change is noticed:
> > going to help-->about under "system" text changes from "cp1252" to
> "UTF-8").
> >
>
> Good, the change did take.
>
> If you're working with an existing project, you may have to change the
> encoding on that project as well.
>
> Go to the Properties panel by right-mouse clicking on the project, and
> selecting Properties (should be at the bottom, at least it is on
> NetBeans 8.1).
>
> On the Sources panel at the bottom, make sure that the encoding is UTF-8.
>
> Note that for existing projects you will probably have to change this.
>
> Also note that for existing files, you'll probably have to do the
> following:
>
> 1. Delete your Hebrew
> 2. Outside of NetBeans change that file to UTF-8
> 3. Open in NetBeans
> 4. Add the Hebrew
>
> I know, it's messy, but again NetBeans does not have a plugin to do this
> internally.
>
> >
> >>
> >> Also, if you're using Maven with NetBeans, UTF-8 has to be set there as
> >> well. My projects contain the following in pom.xml:
> >>
> >> <properties>
> >> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> >> <!-- more stuff -->
> >> </properties>
> >>
> >
> > I don't think I use Maven for this. I use the default build process (for
> my
> > development environment) ie: I right click the project and click "run".
> For
> > my production I build with "gulp".
>
> I don't know anything about gulp and how it handles UTF-8 on a Windows
> platform.
>
> I did try my experiment with a standard (ant build) NetBeans project and
> used the same method to run it.
>
> I'm using NetBeans 8.1 with the latest update on Windows 7 64 bit.
> I'm using JRE 1.8.0_74.
> I'm using Tomcat 7.0.68
>
> >
> >
> >>
> >> If you have cygwin installed on Windows, you can use the following:
> >>
> >> file -bi [filename]
> >>
> >
> > Which file am I supposed to do this for?
>
> Any file that contains non-ascii characters. It should (hopefully) show
> something like the following:
>
> text/html; charset=utf-8
>
> This is for index.jsp after I translated Hello World to Hebrew and
> pasted it in.
>
>
> I also did a servlet, and here's what I got:
>
> text/html; charset=utf-8
>
> (since I have HTML in my servlet - urp)
>
> >
> >
> >>
> >> will tell you the encoding and mime-type.
> >>
> >> iconv will help you convert from us-ascii to UTF-8. The syntax is:
> >>
> >> iconv -f [from-encoding] -t [to-encoding] [input-file] > output-file
> >>
> >
> > Are you suggesting I convert all of my source files to UTF-8?
>
> See previous post for fixing existing files. You may have to re-enter
> non-ascii characters.
>
> > Will all new files that are created now be in UTF-8 at least? Because I
> > just created a new servlet for testing purposes (after the
> > -J-Dfile.encoding property was added) and hebrew urls still aren't found.
> >
>
> New files will be created and shown as us-ascii (at least on my system).
> However, as soon as you add non-ascii text and save the file, it should
> be saved as UTF-8.
>

Yes, this is what happens for me too.


>
> Make sure that any output that you're generating has the encoding set to
> UTF-8.
>
> Also, make sure your connector is set to UTF-8 with:
>
> URIEncoding="UTF-8"
>
> This gets output with UTF-8. In other words, if I paste the Google
> translate to Hebrew output for "Hello World" into either a servlet or
> JSP page, I see the Hebrew output displayed in my browser.
>
> Unfortunately, when I tried a URL in web.xml, this did not work.
>
> The browser sent an encoded string. I tried firefox with the charset
> plugin, but the tamper plugin still showed an encoded (not UTF-8) URL
> being sent.
>
> Using the encoded string in web.xml as a URL pattern did not work.
>
> Obviously I am a bit of a neophyte when it comes to seriously encoding a
> web application for UTF-8, although I can get output to work.
>

Right, if I understood you correctly, this is the same exact problem I am
having. All of my content displays fine (this is "character encoding") but
I cannot map urls in hebrew (this is "URL encoding"). This is the problem I
am having (note also that I have no problem with query strings in utf8
either).


>
> I'll try to play with this later and see if I have any ideas.
>

Thank you. If you get the URL's working I'll try to mimic your set up.


>
> >
> >>
> >> I suspect there are native Windows tools to do this, but I'd have to
> >> wander about and find them.
> >>
> >> Notepad will tell you when you open a file what encoding the file is.
> >> You could then do a "save as" and select the correct encoding.
> >>
> >> Sadly, NetBeans does not have a plugin to do this.
> >>
> >> . . . just my two cents
> >>
> >
> > Thanks.
> >
> >
> >> /mde/
>
> . . . just my two cents
> /mde/
>
>

Re: Mapping servlet to non English url pattern

Posted by Mark Eggers <it...@yahoo.com.INVALID>.
Yuval,

Notes are inline (I hope). This is quickly becoming a NetBeans question.

On 3/9/2016 1:38 AM, Yuval Schwartz wrote:
> Thanks Mark, follow up questions below:
> 
> On Wed, Mar 9, 2016 at 1:26 AM, Mark Eggers <it...@yahoo.com.invalid>
> wrote:
> 
>> Yuval,
>>
>> On 3/8/2016 2:35 PM, Yuval Schwartz wrote:
>>> On Tue, Mar 8, 2016 at 10:53 PM, Mark Thomas <ma...@apache.org> wrote:
>>>
>>>> On 08/03/2016 20:20, Christopher Schultz wrote:
>>>>> Yuval,
>>>>>
>>>>> On 3/8/16 12:38 PM, Yuval Schwartz wrote:
>>>>>> Hello Christopher, thanks, responses below.
>>>>>
>>>>>> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
>>>>>> chris@christopherschultz.net> wrote:
>>>>>
>>>>>> Yuval,
>>>>>
>>>>>> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
>>>>>>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
>>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> I want to map my servlet to a Hebrew url pattern.
>>>>>
>>>>>> Hmm.
>>>>>
>>>>>>>>> I tried placing the hebrew url pattern both in the
>>>>>>>>> "@webservlet" annotation (urlpatterns attribute) and in the
>>>>>>>>> the web.xml file. In both cases it doesn't work, it's as if
>>>>>>>>> there's nothing mapped to the url specified.
>>>>>>>>>
>>>>>>>>> I though to specify the URIEncoding parameter of the
>>>>>>>>> connector but saw that this defaults to "utf-8" in tomcat 8.
>>>>>
>>>>>> Yes, it does.
>>>>>
>>>>>> So you are trying to set the url-pattern for a servlet mapping?
>>>>>
>>>>>> When you do it -- either using @WebServlet or <servlet-mapping> --
>>>>>> can you connect via JMX to observe the pattern that's been read
>>>>>> into the configuration? First, I'd want to make sure that the
>>>>>> Hebrew characters haven't been destroyed by the loading process of
>>>>>> the XML file or by the compiler, or even by Tomcat.
>>>>>
>>>>>
>>>>>>> Can you give me some direction on how I would do this? Maybe a
>>>>>>> little more detail on jmx? There could be encoding/decoding going
>>>>>>> on in the browser (firefox) and in all the elements you mentioned
>>>>>>> on the server side. Any way to see the final String that the
>>>>>>> server is using to match the Url pattern?
>>>>>
>>>>> Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
>>>>> the configuration through it.
>>>>>
>>>>> Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
>>>>> that contains a JMX client... both jconsole and VisualVM require that
>>>>> you go to the "plug-ins" configuration and install an
>>>>> easy-to-find-and-install plug-in for JMX) on the same machine (it's
>>>>> easiest this way).
>>>>>
>>>>> (I just checked, and VisualVM calls the plug-in
>>>>> "VisualVM-MBeans".)visualvisual
>>>>>
>>>>> Then, connect to the Tomcat instance and go to the BMeans tab.
>>>>>
>>>>> You'll find your servlet under
>> /Catalina/Servlet/host/context/[servlet].
>>>>> ..
>>>>>
>>>>>
>>>>> Aw, crap. The mappings themselves aren't actually published via JMX.
>> Hmm
>>>>
>>>> Yes they are.
>>>>
>>>> You need to look at the operations. findMappings() will list them.
>>>>
>>>
>>> I did this and it worked:
>>> The english patterns show up fine, as expected.
>>> The hebrew pattern shows up as a bunch of question marks (eg:
>>> ????-?????-????)
>>> The URLEncoded pattern shows up as wierd symbols (eg: diamond shape, tm
>>> symbol).
>>>
>>> Could this be something in my IDE (Netbeans) settings? The logs for
>>> example, display hebrew characters as question marks. Although my project
>>> encoding is set as UTF-8.
>>>
>>> Thanks.
>>>
>>>
>>>
>>>>
>>>> Mark
>>
>> Are you developing on Windows? (ah, you are)
>>
>> If so, could you check how you launch NetBeans? My netbeans.conf file
>> contains this on the netbeans_default_options line:
>>
>> -J-Dfile.encoding=UTF-8
>>
> 
> I tried this, still doesn't fix the issue (Although a change is noticed:
> going to help-->about under "system" text changes from "cp1252" to "UTF-8").
> 

Good, the change did take.

If you're working with an existing project, you may have to change the
encoding on that project as well.

Go to the Properties panel by right-mouse clicking on the project, and
selecting Properties (should be at the bottom, at least it is on
NetBeans 8.1).

On the Sources panel at the bottom, make sure that the encoding is UTF-8.

Note that for existing projects you will probably have to change this.

Also note that for existing files, you'll probably have to do the following:

1. Delete your Hebrew
2. Outside of NetBeans change that file to UTF-8
3. Open in NetBeans
4. Add the Hebrew

I know, it's messy, but again NetBeans does not have a plugin to do this
internally.

> 
>>
>> Also, if you're using Maven with NetBeans, UTF-8 has to be set there as
>> well. My projects contain the following in pom.xml:
>>
>> <properties>
>> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>> <!-- more stuff -->
>> </properties>
>>
> 
> I don't think I use Maven for this. I use the default build process (for my
> development environment) ie: I right click the project and click "run". For
> my production I build with "gulp".

I don't know anything about gulp and how it handles UTF-8 on a Windows
platform.

I did try my experiment with a standard (ant build) NetBeans project and
used the same method to run it.

I'm using NetBeans 8.1 with the latest update on Windows 7 64 bit.
I'm using JRE 1.8.0_74.
I'm using Tomcat 7.0.68

> 
> 
>>
>> If you have cygwin installed on Windows, you can use the following:
>>
>> file -bi [filename]
>>
> 
> Which file am I supposed to do this for?

Any file that contains non-ascii characters. It should (hopefully) show
something like the following:

text/html; charset=utf-8

This is for index.jsp after I translated Hello World to Hebrew and
pasted it in.


I also did a servlet, and here's what I got:

text/html; charset=utf-8

(since I have HTML in my servlet - urp)

> 
> 
>>
>> will tell you the encoding and mime-type.
>>
>> iconv will help you convert from us-ascii to UTF-8. The syntax is:
>>
>> iconv -f [from-encoding] -t [to-encoding] [input-file] > output-file
>>
> 
> Are you suggesting I convert all of my source files to UTF-8?

See previous post for fixing existing files. You may have to re-enter
non-ascii characters.

> Will all new files that are created now be in UTF-8 at least? Because I
> just created a new servlet for testing purposes (after the
> -J-Dfile.encoding property was added) and hebrew urls still aren't found.
> 

New files will be created and shown as us-ascii (at least on my system).
However, as soon as you add non-ascii text and save the file, it should
be saved as UTF-8.

Make sure that any output that you're generating has the encoding set to
UTF-8.

Also, make sure your connector is set to UTF-8 with:

URIEncoding="UTF-8"

This gets output with UTF-8. In other words, if I paste the Google
translate to Hebrew output for "Hello World" into either a servlet or
JSP page, I see the Hebrew output displayed in my browser.

Unfortunately, when I tried a URL in web.xml, this did not work.

The browser sent an encoded string. I tried firefox with the charset
plugin, but the tamper plugin still showed an encoded (not UTF-8) URL
being sent.

Using the encoded string in web.xml as a URL pattern did not work.

Obviously I am a bit of a neophyte when it comes to seriously encoding a
web application for UTF-8, although I can get output to work.

I'll try to play with this later and see if I have any ideas.

> 
>>
>> I suspect there are native Windows tools to do this, but I'd have to
>> wander about and find them.
>>
>> Notepad will tell you when you open a file what encoding the file is.
>> You could then do a "save as" and select the correct encoding.
>>
>> Sadly, NetBeans does not have a plugin to do this.
>>
>> . . . just my two cents
>>
> 
> Thanks.
> 
> 
>> /mde/

. . . just my two cents
/mde/


Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
Thanks Mark, follow up questions below:

On Wed, Mar 9, 2016 at 1:26 AM, Mark Eggers <it...@yahoo.com.invalid>
wrote:

> Yuval,
>
> On 3/8/2016 2:35 PM, Yuval Schwartz wrote:
> > On Tue, Mar 8, 2016 at 10:53 PM, Mark Thomas <ma...@apache.org> wrote:
> >
> >> On 08/03/2016 20:20, Christopher Schultz wrote:
> >>> Yuval,
> >>>
> >>> On 3/8/16 12:38 PM, Yuval Schwartz wrote:
> >>>> Hello Christopher, thanks, responses below.
> >>>
> >>>> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
> >>>> chris@christopherschultz.net> wrote:
> >>>
> >>>> Yuval,
> >>>
> >>>> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
> >>>>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
> >>>>>>>
> >>>>>>> Hello,
> >>>>>>>
> >>>>>>> I want to map my servlet to a Hebrew url pattern.
> >>>
> >>>> Hmm.
> >>>
> >>>>>>> I tried placing the hebrew url pattern both in the
> >>>>>>> "@webservlet" annotation (urlpatterns attribute) and in the
> >>>>>>> the web.xml file. In both cases it doesn't work, it's as if
> >>>>>>> there's nothing mapped to the url specified.
> >>>>>>>
> >>>>>>> I though to specify the URIEncoding parameter of the
> >>>>>>> connector but saw that this defaults to "utf-8" in tomcat 8.
> >>>
> >>>> Yes, it does.
> >>>
> >>>> So you are trying to set the url-pattern for a servlet mapping?
> >>>
> >>>> When you do it -- either using @WebServlet or <servlet-mapping> --
> >>>> can you connect via JMX to observe the pattern that's been read
> >>>> into the configuration? First, I'd want to make sure that the
> >>>> Hebrew characters haven't been destroyed by the loading process of
> >>>> the XML file or by the compiler, or even by Tomcat.
> >>>
> >>>
> >>>>> Can you give me some direction on how I would do this? Maybe a
> >>>>> little more detail on jmx? There could be encoding/decoding going
> >>>>> on in the browser (firefox) and in all the elements you mentioned
> >>>>> on the server side. Any way to see the final String that the
> >>>>> server is using to match the Url pattern?
> >>>
> >>> Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
> >>> the configuration through it.
> >>>
> >>> Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
> >>> that contains a JMX client... both jconsole and VisualVM require that
> >>> you go to the "plug-ins" configuration and install an
> >>> easy-to-find-and-install plug-in for JMX) on the same machine (it's
> >>> easiest this way).
> >>>
> >>> (I just checked, and VisualVM calls the plug-in
> >>> "VisualVM-MBeans".)visualvisual
> >>>
> >>> Then, connect to the Tomcat instance and go to the BMeans tab.
> >>>
> >>> You'll find your servlet under
> /Catalina/Servlet/host/context/[servlet].
> >>> ..
> >>>
> >>>
> >>> Aw, crap. The mappings themselves aren't actually published via JMX.
> Hmm
> >>
> >> Yes they are.
> >>
> >> You need to look at the operations. findMappings() will list them.
> >>
> >
> > I did this and it worked:
> > The english patterns show up fine, as expected.
> > The hebrew pattern shows up as a bunch of question marks (eg:
> > ????-?????-????)
> > The URLEncoded pattern shows up as wierd symbols (eg: diamond shape, tm
> > symbol).
> >
> > Could this be something in my IDE (Netbeans) settings? The logs for
> > example, display hebrew characters as question marks. Although my project
> > encoding is set as UTF-8.
> >
> > Thanks.
> >
> >
> >
> >>
> >> Mark
>
> Are you developing on Windows? (ah, you are)
>
> If so, could you check how you launch NetBeans? My netbeans.conf file
> contains this on the netbeans_default_options line:
>
> -J-Dfile.encoding=UTF-8
>

I tried this, still doesn't fix the issue (Although a change is noticed:
going to help-->about under "system" text changes from "cp1252" to "UTF-8").


>
> Also, if you're using Maven with NetBeans, UTF-8 has to be set there as
> well. My projects contain the following in pom.xml:
>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <!-- more stuff -->
> </properties>
>

I don't think I use Maven for this. I use the default build process (for my
development environment) ie: I right click the project and click "run". For
my production I build with "gulp".


>
> If you have cygwin installed on Windows, you can use the following:
>
> file -bi [filename]
>

Which file am I supposed to do this for?


>
> will tell you the encoding and mime-type.
>
> iconv will help you convert from us-ascii to UTF-8. The syntax is:
>
> iconv -f [from-encoding] -t [to-encoding] [input-file] > output-file
>

Are you suggesting I convert all of my source files to UTF-8?
Will all new files that are created now be in UTF-8 at least? Because I
just created a new servlet for testing purposes (after the
-J-Dfile.encoding property was added) and hebrew urls still aren't found.


>
> I suspect there are native Windows tools to do this, but I'd have to
> wander about and find them.
>
> Notepad will tell you when you open a file what encoding the file is.
> You could then do a "save as" and select the correct encoding.
>
> Sadly, NetBeans does not have a plugin to do this.
>
> . . . just my two cents
>

Thanks.


> /mde/
>
>

Re: Mapping servlet to non English url pattern

Posted by Mark Eggers <it...@yahoo.com.INVALID>.
Yuval,

On 3/8/2016 2:35 PM, Yuval Schwartz wrote:
> On Tue, Mar 8, 2016 at 10:53 PM, Mark Thomas <ma...@apache.org> wrote:
> 
>> On 08/03/2016 20:20, Christopher Schultz wrote:
>>> Yuval,
>>>
>>> On 3/8/16 12:38 PM, Yuval Schwartz wrote:
>>>> Hello Christopher, thanks, responses below.
>>>
>>>> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
>>>> chris@christopherschultz.net> wrote:
>>>
>>>> Yuval,
>>>
>>>> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
>>>>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I want to map my servlet to a Hebrew url pattern.
>>>
>>>> Hmm.
>>>
>>>>>>> I tried placing the hebrew url pattern both in the
>>>>>>> "@webservlet" annotation (urlpatterns attribute) and in the
>>>>>>> the web.xml file. In both cases it doesn't work, it's as if
>>>>>>> there's nothing mapped to the url specified.
>>>>>>>
>>>>>>> I though to specify the URIEncoding parameter of the
>>>>>>> connector but saw that this defaults to "utf-8" in tomcat 8.
>>>
>>>> Yes, it does.
>>>
>>>> So you are trying to set the url-pattern for a servlet mapping?
>>>
>>>> When you do it -- either using @WebServlet or <servlet-mapping> --
>>>> can you connect via JMX to observe the pattern that's been read
>>>> into the configuration? First, I'd want to make sure that the
>>>> Hebrew characters haven't been destroyed by the loading process of
>>>> the XML file or by the compiler, or even by Tomcat.
>>>
>>>
>>>>> Can you give me some direction on how I would do this? Maybe a
>>>>> little more detail on jmx? There could be encoding/decoding going
>>>>> on in the browser (firefox) and in all the elements you mentioned
>>>>> on the server side. Any way to see the final String that the
>>>>> server is using to match the Url pattern?
>>>
>>> Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
>>> the configuration through it.
>>>
>>> Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
>>> that contains a JMX client... both jconsole and VisualVM require that
>>> you go to the "plug-ins" configuration and install an
>>> easy-to-find-and-install plug-in for JMX) on the same machine (it's
>>> easiest this way).
>>>
>>> (I just checked, and VisualVM calls the plug-in
>>> "VisualVM-MBeans".)visualvisual
>>>
>>> Then, connect to the Tomcat instance and go to the BMeans tab.
>>>
>>> You'll find your servlet under /Catalina/Servlet/host/context/[servlet].
>>> ..
>>>
>>>
>>> Aw, crap. The mappings themselves aren't actually published via JMX. Hmm
>>
>> Yes they are.
>>
>> You need to look at the operations. findMappings() will list them.
>>
> 
> I did this and it worked:
> The english patterns show up fine, as expected.
> The hebrew pattern shows up as a bunch of question marks (eg:
> ????-?????-????)
> The URLEncoded pattern shows up as wierd symbols (eg: diamond shape, tm
> symbol).
> 
> Could this be something in my IDE (Netbeans) settings? The logs for
> example, display hebrew characters as question marks. Although my project
> encoding is set as UTF-8.
> 
> Thanks.
> 
> 
> 
>>
>> Mark

Are you developing on Windows? (ah, you are)

If so, could you check how you launch NetBeans? My netbeans.conf file
contains this on the netbeans_default_options line:

-J-Dfile.encoding=UTF-8

Also, if you're using Maven with NetBeans, UTF-8 has to be set there as
well. My projects contain the following in pom.xml:

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- more stuff -->
</properties>

If you have cygwin installed on Windows, you can use the following:

file -bi [filename]

will tell you the encoding and mime-type.

iconv will help you convert from us-ascii to UTF-8. The syntax is:

iconv -f [from-encoding] -t [to-encoding] [input-file] > output-file

I suspect there are native Windows tools to do this, but I'd have to
wander about and find them.

Notepad will tell you when you open a file what encoding the file is.
You could then do a "save as" and select the correct encoding.

Sadly, NetBeans does not have a plugin to do this.

. . . just my two cents
/mde/


Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
On Tue, Mar 8, 2016 at 10:53 PM, Mark Thomas <ma...@apache.org> wrote:

> On 08/03/2016 20:20, Christopher Schultz wrote:
> > Yuval,
> >
> > On 3/8/16 12:38 PM, Yuval Schwartz wrote:
> >> Hello Christopher, thanks, responses below.
> >
> >> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
> >> chris@christopherschultz.net> wrote:
> >
> >> Yuval,
> >
> >> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
> >>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
> >>>>>
> >>>>> Hello,
> >>>>>
> >>>>> I want to map my servlet to a Hebrew url pattern.
> >
> >> Hmm.
> >
> >>>>> I tried placing the hebrew url pattern both in the
> >>>>> "@webservlet" annotation (urlpatterns attribute) and in the
> >>>>> the web.xml file. In both cases it doesn't work, it's as if
> >>>>> there's nothing mapped to the url specified.
> >>>>>
> >>>>> I though to specify the URIEncoding parameter of the
> >>>>> connector but saw that this defaults to "utf-8" in tomcat 8.
> >
> >> Yes, it does.
> >
> >> So you are trying to set the url-pattern for a servlet mapping?
> >
> >> When you do it -- either using @WebServlet or <servlet-mapping> --
> >> can you connect via JMX to observe the pattern that's been read
> >> into the configuration? First, I'd want to make sure that the
> >> Hebrew characters haven't been destroyed by the loading process of
> >> the XML file or by the compiler, or even by Tomcat.
> >
> >
> >>> Can you give me some direction on how I would do this? Maybe a
> >>> little more detail on jmx? There could be encoding/decoding going
> >>> on in the browser (firefox) and in all the elements you mentioned
> >>> on the server side. Any way to see the final String that the
> >>> server is using to match the Url pattern?
> >
> > Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
> > the configuration through it.
> >
> > Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
> > that contains a JMX client... both jconsole and VisualVM require that
> > you go to the "plug-ins" configuration and install an
> > easy-to-find-and-install plug-in for JMX) on the same machine (it's
> > easiest this way).
> >
> > (I just checked, and VisualVM calls the plug-in
> > "VisualVM-MBeans".)visualvisual
> >
> > Then, connect to the Tomcat instance and go to the BMeans tab.
> >
> > You'll find your servlet under /Catalina/Servlet/host/context/[servlet].
> > ..
> >
> >
> > Aw, crap. The mappings themselves aren't actually published via JMX. Hmm
>
> Yes they are.
>
> You need to look at the operations. findMappings() will list them.
>

I did this and it worked:
The english patterns show up fine, as expected.
The hebrew pattern shows up as a bunch of question marks (eg:
????-?????-????)
The URLEncoded pattern shows up as wierd symbols (eg: diamond shape, tm
symbol).

Could this be something in my IDE (Netbeans) settings? The logs for
example, display hebrew characters as question marks. Although my project
encoding is set as UTF-8.

Thanks.



>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Mapping servlet to non English url pattern

Posted by Mark Thomas <ma...@apache.org>.
On 08/03/2016 20:20, Christopher Schultz wrote:
> Yuval,
> 
> On 3/8/16 12:38 PM, Yuval Schwartz wrote:
>> Hello Christopher, thanks, responses below.
> 
>> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz < 
>> chris@christopherschultz.net> wrote:
> 
>> Yuval,
> 
>> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
>>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
>>>>>
>>>>> Hello,
>>>>>
>>>>> I want to map my servlet to a Hebrew url pattern.
> 
>> Hmm.
> 
>>>>> I tried placing the hebrew url pattern both in the
>>>>> "@webservlet" annotation (urlpatterns attribute) and in the
>>>>> the web.xml file. In both cases it doesn't work, it's as if
>>>>> there's nothing mapped to the url specified.
>>>>>
>>>>> I though to specify the URIEncoding parameter of the
>>>>> connector but saw that this defaults to "utf-8" in tomcat 8.
> 
>> Yes, it does.
> 
>> So you are trying to set the url-pattern for a servlet mapping?
> 
>> When you do it -- either using @WebServlet or <servlet-mapping> --
>> can you connect via JMX to observe the pattern that's been read
>> into the configuration? First, I'd want to make sure that the
>> Hebrew characters haven't been destroyed by the loading process of
>> the XML file or by the compiler, or even by Tomcat.
> 
> 
>>> Can you give me some direction on how I would do this? Maybe a
>>> little more detail on jmx? There could be encoding/decoding going
>>> on in the browser (firefox) and in all the elements you mentioned
>>> on the server side. Any way to see the final String that the
>>> server is using to match the Url pattern?
> 
> Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
> the configuration through it.
> 
> Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
> that contains a JMX client... both jconsole and VisualVM require that
> you go to the "plug-ins" configuration and install an
> easy-to-find-and-install plug-in for JMX) on the same machine (it's
> easiest this way).
> 
> (I just checked, and VisualVM calls the plug-in
> "VisualVM-MBeans".)visualvisual
> 
> Then, connect to the Tomcat instance and go to the BMeans tab.
> 
> You'll find your servlet under /Catalina/Servlet/host/context/[servlet].
> ..
> 
> 
> Aw, crap. The mappings themselves aren't actually published via JMX. Hmm

Yes they are.

You need to look at the operations. findMappings() will list them.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Mapping servlet to non English url pattern

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yuval,

On 3/8/16 12:38 PM, Yuval Schwartz wrote:
> Hello Christopher, thanks, responses below.
> 
> On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz < 
> chris@christopherschultz.net> wrote:
> 
> Yuval,
> 
> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
>>>> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
>>>> 
>>>> Hello,
>>>> 
>>>> I want to map my servlet to a Hebrew url pattern.
> 
> Hmm.
> 
>>>> I tried placing the hebrew url pattern both in the
>>>> "@webservlet" annotation (urlpatterns attribute) and in the
>>>> the web.xml file. In both cases it doesn't work, it's as if
>>>> there's nothing mapped to the url specified.
>>>> 
>>>> I though to specify the URIEncoding parameter of the
>>>> connector but saw that this defaults to "utf-8" in tomcat 8.
> 
> Yes, it does.
> 
> So you are trying to set the url-pattern for a servlet mapping?
> 
> When you do it -- either using @WebServlet or <servlet-mapping> --
> can you connect via JMX to observe the pattern that's been read
> into the configuration? First, I'd want to make sure that the
> Hebrew characters haven't been destroyed by the loading process of
> the XML file or by the compiler, or even by Tomcat.
> 
> 
>> Can you give me some direction on how I would do this? Maybe a
>> little more detail on jmx? There could be encoding/decoding going
>> on in the browser (firefox) and in all the elements you mentioned
>> on the server side. Any way to see the final String that the
>> server is using to match the Url pattern?

Yeah, that's why I was suggesting using JMX, since Tomcat exposes all
the configuration through it.

Launch Tomcat, then fire-up jconsole (or VisualVM, or any other tool
that contains a JMX client... both jconsole and VisualVM require that
you go to the "plug-ins" configuration and install an
easy-to-find-and-install plug-in for JMX) on the same machine (it's
easiest this way).

(I just checked, and VisualVM calls the plug-in
"VisualVM-MBeans".)visualvisual

Then, connect to the Tomcat instance and go to the BMeans tab.

You'll find your servlet under /Catalina/Servlet/host/context/[servlet].
..


Aw, crap. The mappings themselves aren't actually published via JMX. Hmm
.

>> I've done a lot of guessing and checking. For example, I used
>> the URLEncoder to get the encoded form of my urls and put that in
>> the url pattern.

Good. So you have some set of Unicode escapes like \u0fe64 or whatever
in the url-pattern string in your annotation?

>> Therefore, the xml loading process/compiler/tomcat/netbeans 
>> shouldn't do anything to change it (in the case where I encode
>> the pattern), but the servlet still isn't found.

Well, if you use annotations, the XML shouldn't be a problem at all,
of course. But you said you were having problems using the
web.xml-based configuration, too, right?

When you type the URL into your browser, are you just typing the
Hebrew right into the browser, or have you UTF/URL-escaped it first
and then copy/pasted it into the browser (or, better yet, provide a
link from another page that isn't giving you any problems).

You might want to make sure that Tomcat is delivering all responses in
UTF-8, so that the browser (hopefully) decides to send the URL for the
*next* page in UTF-8 instead of some weird ISO-8859-1 mess.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlbfNBIACgkQ9CaO5/Lv0PAEswCcD9K3iwDplOASR81WtIMQZVFb
77YAnisxPAcn8/vuAU1PNDQgnvGuLVlo
=LmWf
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Mapping servlet to non English url pattern

Posted by Yuval Schwartz <yu...@gmail.com>.
Hello Christopher, thanks, responses below.

On Tue, Mar 8, 2016 at 6:23 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Yuval,
>
> On 3/8/16 3:14 AM, Yuval Schwartz wrote:
> > Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
> >
> > Hello,
> >
> > I want to map my servlet to a Hebrew url pattern.
>
> Hmm.
>
> > I tried placing the hebrew url pattern both in the "@webservlet"
> > annotation (urlpatterns attribute) and in the the web.xml file. In
> > both cases it doesn't work, it's as if there's nothing mapped to
> > the url specified.
> >
> > I though to specify the URIEncoding parameter of the connector but
> > saw that this defaults to "utf-8" in tomcat 8.
>
> Yes, it does.
>
> So you are trying to set the url-pattern for a servlet mapping?
>
> When you do it -- either using @WebServlet or <servlet-mapping> -- can
> you connect via JMX to observe the pattern that's been read into the
> configuration? First, I'd want to make sure that the Hebrew characters
> haven't been destroyed by the loading process of the XML file or by
> the compiler, or even by Tomcat.
>

Can you give me some direction on how I would do this? Maybe a little more
detail on jmx? There could be encoding/decoding going on in the browser
(firefox) and in all the elements you mentioned on the server side. Any way
to see the final String that the server is using to match the Url pattern?

I've done a lot of guessing and checking. For example, I used the
URLEncoder to get the encoded form of my urls and put that in the url
pattern. Therefore, the xml loading process/compiler/tomcat/netbeans
shouldn't do anything to change it (in the case where I encode the
pattern), but the servlet still isn't found.

Thanks.


> Can you confirm that the browser is sending the URL without ruining it
> as well?
>
> Tomcat's Mapper follows the spec-defined rules for mapping a URL to a
> servlet, so it's possible that another servlet will take-over the
> mapping, depending upon how it's defined. Remember, the spec says that
> an exact-match wins, followed by a prefix-match (/foo/bar/baz/*)
> (longest match wins), followed by an extension-match (*.img), followed
> by things like welcome-file resources, etc.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iEYEARECAAYFAlbe/IMACgkQ9CaO5/Lv0PCupACbBDmQYb9WmxM6R0F+FpKK6bB5
> /DMAnAv7tv6nYOcfQDXFl1NltegV47lA
> =L+ec
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Mapping servlet to non English url pattern

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yuval,

On 3/8/16 3:14 AM, Yuval Schwartz wrote:
> Tomcat version: 8.0.22 Jdk: 1.8.0_05 Server: Amazon Linux
> 
> Hello,
> 
> I want to map my servlet to a Hebrew url pattern.

Hmm.

> I tried placing the hebrew url pattern both in the "@webservlet"
> annotation (urlpatterns attribute) and in the the web.xml file. In
> both cases it doesn't work, it's as if there's nothing mapped to
> the url specified.
> 
> I though to specify the URIEncoding parameter of the connector but
> saw that this defaults to "utf-8" in tomcat 8.

Yes, it does.

So you are trying to set the url-pattern for a servlet mapping?

When you do it -- either using @WebServlet or <servlet-mapping> -- can
you connect via JMX to observe the pattern that's been read into the
configuration? First, I'd want to make sure that the Hebrew characters
haven't been destroyed by the loading process of the XML file or by
the compiler, or even by Tomcat.

Can you confirm that the browser is sending the URL without ruining it
as well?

Tomcat's Mapper follows the spec-defined rules for mapping a URL to a
servlet, so it's possible that another servlet will take-over the
mapping, depending upon how it's defined. Remember, the spec says that
an exact-match wins, followed by a prefix-match (/foo/bar/baz/*)
(longest match wins), followed by an extension-match (*.img), followed
by things like welcome-file resources, etc.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlbe/IMACgkQ9CaO5/Lv0PCupACbBDmQYb9WmxM6R0F+FpKK6bB5
/DMAnAv7tv6nYOcfQDXFl1NltegV47lA
=L+ec
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org