• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat madness!

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,

I have two JSPs that are identical in everything except their names (form1 and form1a) imaginative aren't they? I have found that Tomcat 5.0.28 generates very different servelts for the two JSPs. Not believing my eyes, I deleted the generated servlet from:

C:\Tomcat\work\Catalina\localhost\BeerV1\org\apache\jsp

and reran the app so that the servlet would be regenerated but.... same thing!

Here are the two servelts. Don't worry about reading them. A brief scan and you will see immediately that the structure is completely different. This is not a freak occurance, I have found that when I deploy a JSP several times adding bits of code as I go, that finally this will happen. The only way out seems to be to rename the JSP and start again with a new name. This can't be right!

The first is the new one:



And here is the second:


 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the Tomcat forum.
 
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excuse me if you've already considered this...
But I've got a strong feeling that the pages are saved in different encoding.

Note this is *not* just what's written in the page header, e.g. :
- <%@ page contentType="text/html;charset=UTF-8" ...

Rather, it's how the page is really saved on the file system.
Checking for file encoding on Windows: open the file with Notepad, press "Save As", and look at the 'save' dialog that pops up:
it should contain an 'encoding' field, which can be 'ANSI', "UTF-8", etc...
(You don't need to actually go through with 'saving', just see the current encoding, then cancel).

I think if you test both your JSP files, Notepad would tell they have different encodings.
I get this feeling because with the 2nd JSP, the first 'out.write', looks like this:
- out.write("��< % @ p a g ...
And the little '��' scramble at the beginning of the file is usually a 'file encoding' indicator.

Please reply if that works
Good luck.
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sol Mam Orn,

It is exactly as you said! And it never occurred to me, so thanks! One file is ANSI the other Unicode. The ANSI generates the correct servlet, so would you say I should just use ANSI in future or is it a matter of matching the charset to the file encoding? So if I want to save the jsp file as a unicode, I have to include that in pageEncoding of the page directive?
 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's my 2p on it (earned, I might note, through several *painful* weeks of converting a silly webapp to support Eastern languages...).

1)
Yep, usually (if you don't tweak Tomcat's Connector configuration), it's a matter of matching the 'physical' file format (as seen on 'save as'), with the < @%pag.. > encoding declaration...
You're probably aware that when the server transmits a page to the a browser, it first sends a 'content-type' header, telling the browser which type/encoding of data to expect (watchable on IE6, through view->encoding).
Now, your Tomcat usually formats that header based on the contentType/encoding declared of < %@ page ... > . If that header doensn't match the physical data, then the browser might interpret it incorrectly, usually ending up showing junk.

2) ANSI can be fine for simple english pages, but it doesn't support all foreign languages (and some special characters) - for those, use UTF-8 or unicode (but I *think* UTF taks up less space, on average).


Good luck
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic