removal of product name/version

2008-08-12 Thread Tommy Pham
Hi,

I'm looking for a way to remove the product name and/or version from the server 
header and default http errors (without defining my own custom error-page).  I 
know it's possible for apache using ServerSignature and ServerTokens, also 
possible for glassfish v2 using a jvm option.  I've looked at the 
tomcat.apache.org's docs and can't seem to find anything close it.  Would 
someone please point me in the right direction?

TIA,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: removal of product name/version

2008-08-12 Thread Tommy Pham
Hi Chris,

--- On Tue, 8/12/08, Christopher Schultz [EMAIL PROTECTED] wrote:

 Tommy,
 
 Tommy Pham wrote:
 | I'm looking for a way to remove the product name
 and/or version from
 | the server header and default http errors (without
 defining my own
 | custom error-page).  I know it's possible for apache
 using
 | ServerSignature and ServerTokens, also possible for
 glassfish v2
 | using a jvm option.  I've looked at the
 tomcat.apache.org's docs and
 | can't seem to find anything close it.  Would someone
 please point me
 | in the right direction?
 
 If you mean the pages displayed to the client during an
 error condition,
 then you must define your own error-pages. These default
 ones are, IIRC,
 hard-coded into Tomcat.
 
 - -chris

Thanks all for the reply.  Somehow I missed that attribute.  Looks I'll have to 
define the error-pages.  If I specify in the web.xml in the conf folder, does 
apply to all web apps deployed for that host/virtual host?  And what happens if 
certain web apps define their own error-page in in it's own web.xml?  Does the 
web app's definition override the host/virtual host's?

Thanks,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Intgrate Tomcat and PHP in winxp

2008-08-17 Thread Tommy Pham
Hi Radhakrishna,

--- On Sun, 8/17/08, Radhakrishnavangara [EMAIL PROTECTED] wrote:

 From: Radhakrishnavangara [EMAIL PROTECTED]
 Subject: Intgrate Tomcat and PHP in winxp
 To: users@tomcat.apache.org
 Date: Sunday, August 17, 2008, 3:24 PM
 Hi,
 
 Could you please let me know the step by step instructions
 for integrating
 Tomcat with PHP on Win XP. I have tried implementing
 various methodologies
 to integrate the same , but i could not achieve any
 breakthrough on the
 same. Below are some of the links to the articles which i
 have referred.
 Could you please go through the same and clarify me on this
 issue. 
 
 http://www.windowscomputer.com/node/3814
 http://www.theasolutions.com/tutorials/tomcatphp.jsp
 http://the-double-0-project.net/blog/?tag=tomcat
 http://209.85.175.104/search?q=cache:szlV41sb9qwJ:uranus.im.chu.edu.tw/~dtchang/phpexplorer/html/download.php%3Ffn%3D..%252F..%252Fpub%252F.%252Fdownload%252Fapache_tomcat%252FRunning%2Bphp%2B5.x%2Bon%2Bwindows%2Busing%2Btomcat%2B4.x%2Bor%2B5.x%2B-%2BSimple%2BThoughts%2B-%2BJava%2Band%2BWeb%2BSoftware.pdf+angusman+tomcathl=enct=clnkcd=7gl=in
 http://www.duminy.fr/blog/?p=22language=en
 
 Thanks and Regards,
 Radhakrishna
 -- 
 View this message in context:
 http://www.nabble.com/Intgrate-Tomcat-and-PHP-in-winxp-tp19022523p19022523.html
 Sent from the Tomcat - User mailing list archive at
 Nabble.com.
 
IMO if you want to use PHP with Tomcat, it's best you read the documentation 
for both products and their technology as it will help you secure the 
server/platform and troubleshoot any problems that may arise including 
application crashes and security breaches.
For PHP5: http://www.php.net/manual/en/
For Tomcat6: http://tomcat.apache.org/tomcat-6.0-doc/index.html
For Tomcat5.5: http://tomcat.apache.org/tomcat-5.5-doc/index.html

You can just go through the installation steps w/o doing the actual 
installation to see what you have available.  Though I haven't tried this 
method, I think you can run PHP as CGI in Tomcat.  You'll just have to edit the 
web.xml in $CATALINA_HOME/conf folder and follow PHP's instruction of 
installing as CGI.

The method I prefer and have tested to work (in Unix environment although on 
Windows should be similar) is running Apache HTTPD server with PHP as a mod and 
use the connector to connect to Tomcat.  If this method is used, it's easier to 
implement other technologies later such Perl, Python and Mono (for .Net) inside 
Apache HTTPD as mod-*.

But you may want to evaluate your needs and goals before choosing ;)

Regards,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Tomcat 6.0.18 JavaEE 5/EJB3.0

2008-08-17 Thread Tommy Pham
Hi,

I'm trying to develop a web app using JDK1.6 and Tomcat 6.0.18 and JPA.  When 
creating a new web app in Netbeans 6.1, I chose the Java EE 5 version.  Then I 
proceed to create Entity Classes from Databases which were successful.  If I 
try to create JSF pages from Entity Classes, I get:
The class javax.transaction.UserTransaction is unavailable. Add an appropriate 
jar file ...

After adding javaee.jar from Glassfish v2 into my web app and deployed the web 
app, I got this error:
INFO: Illegal access: this web application instance has been stopped already.  
Could not load java.lang.Object.  The eventual following stack trace is caused 
by an error thrown for debugging purposes as well as to attempt to terminate 
the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)

I think it's because of the javaee.jar causing conflict with tomcat's jar files.

I know that Tomcat is only a web container but is there a way I can implement 
JavaEE5/EJB3.0 for full Persistence support without having to switch to 
Geronimo 2.x or Glassfish v2/v3?  (I think this is a stupid question but I just 
want to know my options :) I rather not switch to Glassfish if I don't have to 
because of default directory browsing Glassfish has :D

Thanks,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat 6.0.18 JavaEE 5/EJB3.0

2008-08-17 Thread Tommy Pham
Hi Johnny,

--- On Sun, 8/17/08, Johnny Kewl [EMAIL PROTECTED] wrote:
 
 Tommy if you havnt already... have a look at Visual Web
 Pages... it has the 
 dB wizards and it works with TC.
 Doesnt use JPA, it uses Cached Rowsets to persist... which
 are actually 
 easier to understand, I think ;)
 
 ... nothing stopping you from making a lib that uses JPA,
 and then using 
 that in TC, but you not going to get the dB wizards to work
 with the web...
 
 Visual Web Pages is the JSF technology... I didnt even know
 Sun had got JPA 
 and WEB wizards working yet ;)
 Anyway... TC and JSF are friendly... via VWP... if you wont
 to give that a 
 spin on NB
 Make a web project... select VWP... choose TC as the
 server... maybe ;)
 

I did try out VWP before but I had some problems with it regarding db 
automatically generating PK. 
http://forums.java.net/jive/message.jspa?messageID=259409#259409
Since my database is normalized creating multiple one-to-many relationships, I 
need the generated key to insert into other tables at the same time.  With 
Persistence, I can make full use of transaction if any part of the inserts 
failed w/o having to worry much about incomplete/junk data in my db because 
Persistence can give me the generated key right after insert :)

Thanks,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat 6.0.18 JavaEE 5/EJB3.0

2008-08-17 Thread Tommy Pham

--- On Sun, 8/17/08, Johnny Kewl [EMAIL PROTECTED] wrote:

 Tommy I actually have my own persist framework... but just
 having a quick 
 squiz at that, that problem is just a normal Java thing...
 ie type 
 conversions can be a little tricky...
 
 int and Integer are not the same thing in Java...
 
 its going to be something like
 
 int i = Integer.parseInt(TheThing);
 I think...
 
 same story for long... ie one is a primitive type and one
 is a class... diff 
 mem structure but Java alsways has a slightly obscure
 conversion 
 somewhere...
 
 Have fun
 Anyway, just wanted to make sure you knew VWP was there
 
 
Thanks,  because of VWP (with table navigation/pagination and sort features), 
that's why I stuck with Netbeans for my IDE :D.  Only drawback IMO with 
Netbeans is lack of various server support like Eclipse.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Intgrate Tomcat and PHP in winxp

2008-08-18 Thread Tommy Pham

--- On Mon, 8/18/08, Radhakrishnavangara [EMAIL PROTECTED] wrote:

 From: Radhakrishnavangara [EMAIL PROTECTED]
 Subject: Re: Intgrate Tomcat and PHP in winxp
 To: users@tomcat.apache.org
 Date: Monday, August 18, 2008, 12:55 PM
 Hi Tommy,
 
 That was really informative. But let me explain you the
 actual scenario. I
 am using an application called phpESP ( a survey tool
 developed in PHP) and
 running on Apache httpd. The application is running fine,
 but it is
 consuming lot of memory space in the server. So we have
 decided to move the
 application and deploy on a lighter application server.
 That's the reason we
 have decided to deploy on Tomcat. So could you please let
 me know your
 opinion on the same. 
 
 Also i am a beginner to PHP and Tomcat. Also i have spend
 lot of time on
 this and now i have to some how finish this task. Offline i
 will take your
 guidance on understanding this technology. For now could
 you please explain
 us with the step by step instruction on how to finish the
 same task.
 
 Regards,
 Radhakrishna
 

Radhakrishnavangara,

If your app is pure PHP (and perhaps some Javascript/AJAX) and you have no 
intention of migrating to another platform, your best bet is sticking with 
Apache httpd and troubleshoot your performance issue.  Otherwise you're just 
making things more complicated.  As Alan pointed out, there downside to running 
PHP as CGI which you may want to consider is worth it to migrate to another 
platform server which has no main use for you?  If you do intend to migrate to 
another platform, then just follow as Johnny pointed out.

As for performance, rule which i go by is run lean meaning take out any httpd 
mods and any php extensions you have no use for (you will need to refer to 
Apache httpd's and PHP manual for this).  By removing unnecessary mods and 
extensions, you reduce the memory consumption.  Then start looking at your 
server/system for unnecessary processes/services (you'll have to refer to your 
OS documentation for this).  If it's still running slow, then you'll have to 
the dirty work of debugging and fine tuning your app (if you didn't build it, 
you may refer to developers/provider whom  build it for help) since the app you 
use may free the resources it consumes.  Thus, as time goes on, your server 
will be running slow.  This is a problem with all apps regardless of what 
server/platform the app running is on.  Some server/platform has some method of 
garbage collection but you'll need to read the server's/platform's 
documentation to know what you have to work with.

Regards,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Struts vs JSF (poll?)

2008-08-23 Thread Tommy Pham
Hi everyone,

This maybe out of scope for this list but I wanted to know more about Struts vs 
JSF other this old article [1].  Which are are deployed mostly on your TC 
server(s)/cluster(s)?  If any Java developers are on this list, which platform 
API do you prefer for quick development (to meet deadline), performance, 
security management (user authentication and level restriction) etc... since 
both are based on MVC despite their different implementations(?).

Since there isn't a JSR for Struts, has Struts been around before JCP is 
formed?  And why is there not a JSR for Struts now (just curious)?

As for JSF, which implementation is used by/for your app(s)? Sun/NetBeans? 
Apache's MyFaces? or Others (please list)?  I'm somewhat disappointed Netbeans 
support for JSF and Struts in that Netbeans bundled libs support used older 
Apache Commons lib version (even for the current v6.1), although this could be 
updated but I don't know whether it will break the integration of Netbeans' 
VWP.  Even the tutorial/trails on NetBeans site regarding Struts (although this 
can be compensated at Struts' web site) is very limited perhaps because of the 
(biased?) Struts weak integration to favor or push more on JSF/Visual JSF?

I need to evaluate my options of API and IDE before I dedicate several projects 
since the performance of Netbeans is getting worse by every release comparing 
to Eclipse.  As for server, I've decided already ;)

TIA,
Tommy

[1] http://websphere.sys-con.com/node/46516

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to block part of application based on ip filtering

2008-08-24 Thread Tommy Pham

--- On Sun, 8/24/08, Meir Yanovich [EMAIL PROTECTED] wrote:

 From: Meir Yanovich [EMAIL PROTECTED]
 Subject: How to block part of application based on ip filtering
 To: users@tomcat.apache.org
 Date: Sunday, August 24, 2008, 7:38 AM
 Hello all
 im using tomcat as the web server , and i have reverse
 proxy that
 redirect to the tomcat
 i like to be able to restrict the users that redirected
 from the
 reverse proxy server to be able to
 enter only one section of the application .
 now i was reading the configuration and i found only the
 possibility
 to allow / deny based on ip with :
 org.apache.catalina.valves.RemoteAddrValve , but how can i
 allow from
 ip x to enter only section Y of the application .
 thanks
 

Hi Meir,

I think the only possible approach is within the application itself since you 
want to limit access to certain portions of the application.  You can use the 
request.getRemoteAddr() of the HttpServletRequest.  If you store the 
information (URL  IP) in the database, you can change it dynamically as you 
need to :).  Also, you can log for repeated attempts of hacking ;)

Regards,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Problems with running 64-bit Tomcat 6 as a Windows service

2008-09-04 Thread Tommy Pham

--- On Wed, 9/3/08, Brian Clark [EMAIL PROTECTED] wrote:

 From: Brian Clark [EMAIL PROTECTED]
 Subject: Problems with running 64-bit Tomcat 6 as a Windows service
 To: Tomcat Users users@tomcat.apache.org
 Date: Wednesday, September 3, 2008, 10:00 PM
 Hello,
 
 I am trying to get Tomcat 6.0.18 to run on my Win2k3 x64
 edition server. I basically did the same thing talked about
 here:
 http://markmail.org/message/kptleixb6duxgwhm
 but it didn't work for me. I didn't use the
 service.bat install though. I installed the service manually
 with the sc.exe command.
 
 I am using the 64-bit 1.6.0_06 JDK.  I don't get any
 Windows errors, the service start process just times out. My
 catalina and jakarta logs don't have anything useful.
 The logs seem to indicate that Tomcat started up fine--only
 it didn't. 
 
 When I start up Tomcat from the command line, it works
 fine. I did have to check the box in tomcat6w.exe to allow
 the service to interact with the desktop to run it from the
 command line though. That seemed a little weird. 
 
 Anyone successful in running Tomcat 6 as a 64-bit service? 
 
 Thanks,
 Brian

Hi Brian,

Are you using the zip install or exe install? It's easier to use the exe 
install.  Then download these tomcat*.exe at [1] and replace the files in bin 
folder.  If you need bat script files, you can extract those from the zip.  I 
have it running fine on WinXP x64.

Regards,
Tommy

[1] 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/tags/TOMCAT_6_0_18/res/procrun/amd64/

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts vs JSF (poll?)

2008-09-04 Thread Tommy Pham
Hello everyone,

Thank you all for your replies and positive input.  I'll read more about DWR, 
Wicket, and Tomcat MVC model to decide what's best for my project(s).

Johnny, if by chance you manage to find the links to the Tomcat MVC model, 
would you please send it?  I didn't have much success googling it.

Thanks,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: UnauthorizedAccessException error while running WMI in tomcat

2008-09-08 Thread Tommy Pham
--- On Mon, 9/8/08, new_bie_tomcat [EMAIL PROTECTED] wrote:

 From: new_bie_tomcat [EMAIL PROTECTED]
 Subject: Re: UnauthorizedAccessException error while running WMI in tomcat
 To: users@tomcat.apache.org
 Date: Monday, September 8, 2008, 3:06 AM
 Hi Mark,
 Thanks a lot for your reply. I am not able to find out
 exactly where to
 change the permission. I am using Tomcat 5.5. I have logged
 in to the
 machine, using the same user login as the remote machine.
 Both of the
 machine are in the same domain. In tomcat Properties Log on
 Tab i have
 logged in as the same login ID of the local/ remote
 machine. But still i am
 getting the same error.Please let me know where exactly i
 need to configure
 properly.
 
 Thanks again..
 

Hi,

Since you're in the domain and if my memory serves correctly (it's been a while 
since I worked w/ windows domains), you'll need to have proper access rights to 
access the registry.  Not all WMI commands will work with User/Power User 
rights.  You'll need full Administrator's rights on the target system if you 
want to use WMI to it's fullest.  You may want to check your domain policy and 
the local systems' policy (if any is defined).  Logging into a machine does not 
mean that account have the appropriate access rights, especially if you're 
trying access HKLM, HKCR, and HKUSERS.  You may want to look into impersonation 
to lessen the security risk of unwanted full domain access ;) 

Regards,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Balance and sync data

2008-09-18 Thread Tommy Pham

--- On Wed, 9/17/08, Hassan Schroeder [EMAIL PROTECTED] wrote:

 From: Hassan Schroeder [EMAIL PROTECTED]
 Subject: Re: Balance and sync data
 To: Tomcat Users List users@tomcat.apache.org
 Date: Wednesday, September 17, 2008, 6:13 PM
 On Wed, Sep 17, 2008 at 2:57 PM, Christopher Schultz
 [EMAIL PROTECTED] wrote:
 
  Why not have your upload servlet invoke rsync when
 a new file has
  been stored?
 
  You're not seriously suggesting that as a viable
 production strategy,
  are you?
 
  [  IM IN UR DURECTRY COPYNG UR IMAGES  ]
 
 Sure -- why not? It works nicely for a use case like this.
 And exec'ing
 a process as needed beats spawning one every minute!
 
  NFS, baby. NFS.
 
 Um, single point of failure?  :-)
 

What if NFS source is from DRBD [1]?  DRBD provides alternative to an expensive 
single HA system ;)

[1] http://www.drbd.org/



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Tomcat 6.0.16 serving 40K jpg files

2008-07-31 Thread Tommy Pham
Hi,

I just start learning Java programming a while back and doing some 
tutorials/learning trails at netbeans.org.  One of the tutorial using Visual 
JSF, http://www.netbeans.org/kb/60/web/fileupload.html, I'm doing is not 
working as I think it should and I'm not getting any http error or Java 
exception.  I can upload the image fine and it will display any jpg ~40k or 
less.  If the image size is larger, it doesn't show.  I tried to browse the 
40k+ image directly instead of the image tag, it doesn't show also.  Does 
anyone know why is this?  I tried google for problem but unable to find any.  
The development platform is WinXP x64 JDK6 1.6.0_06, Tomcat 6.0.16. The default 
installation configurations have not been modified.

TIA,
Tommy

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat 6.0.16 serving 40K jpg files

2008-07-31 Thread Tommy Pham
Hi Markus,


--- On Thu, 7/31/08, Markus Schönhaber [EMAIL PROTECTED] wrote:

 From: Markus Schönhaber [EMAIL PROTECTED]
 Subject: Re: Tomcat 6.0.16 serving 40K jpg files
 To: users@tomcat.apache.org
 Date: Thursday, July 31, 2008, 1:28 PM
 Tommy Pham wrote:
 
  http error or Java exception.  I can upload the image
 fine and it
  will display any jpg ~40k or less.  If the image size
 is larger, it
  doesn't show.  I tried to browse the 40k+ image
 directly instead of
  the image tag, it doesn't show also.  Does anyone
 know why is this?
  I tried google for problem but unable to find any. 
 The development
  platform is WinXP x64 JDK6 1.6.0_06, Tomcat 6.0.16.
 The default
  installation configurations have not been modified.
 
 Although the limit being ~40k hints against this you might
 have run into
 https://issues.apache.org/bugzilla/show_bug.cgi?id=44494
 Try to run the webapp on Tomcat 6.0.18, which was released
 today and
 where the above bug should be fixed.
 
 Regards
   mks
 

Thanks for the reply.  Yup, 6.0.18 works!! :)

Thanks again,
Tommy



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing a URL to see if a param exists

2008-08-05 Thread Tommy Pham

--- On Tue, 8/5/08, David Wall [EMAIL PROTECTED] wrote:

 From: David Wall [EMAIL PROTECTED]
 Subject: Parsing a URL to see if a param exists
 To: Tomcat Users List users@tomcat.apache.org
 Date: Tuesday, August 5, 2008, 7:17 PM
 Is there an API call to parse an URL I have as a String so
 that I can 
 determine if a given param exists? 
 

http://java.sun.com/docs/books/tutorial/networking/urls/urlInfo.html

It breaks down every component of the url (protocol, domain name, etc).  Is 
that what you're looking for?

 I know that when processing from Tomcat, I can do 
 request.getParameterValues() for the URL of my servlet, but
 I'd like to 
 know if the URL used to arrive at my page includes a given
 parameter on 
 the URL itself (and not from a POST hidden param that will
 also be 
 returned by getParameterValues).
 
 Thanks,
 David
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing a URL to see if a param exists

2008-08-05 Thread Tommy Pham

--- On Tue, 8/5/08, David Wall [EMAIL PROTECTED] wrote:

 From: David Wall [EMAIL PROTECTED]
 Subject: Re: Parsing a URL to see if a param exists
 To: Tomcat Users List users@tomcat.apache.org
 Date: Tuesday, August 5, 2008, 7:50 PM
 
 http://java.sun.com/docs/books/tutorial/networking/urls/urlInfo.html
 
  It breaks down every component of the url (protocol,
 domain name, etc).  Is that what you're looking for?

 
 Not really since I just need to process the query string
 portion to see 
 if a given param exists or not.  I'm using a simple
 homegrown parser now:
 
 public boolean isParamInUrl(String url, String
 paramName)
 {
 int pos = url.indexOf(?);
 if ( pos  0 )
 url = url.substring(pos);
 String[] paramValues =
 url.split();
 if ( paramValues == null )
 return false;

 for( String paramValue : paramValues )
 {
 String[] paramAndValue =
 paramValue.split(=);
 if ( paramAndValue == null ||
 paramAndValue.length != 2 )
 return false;
 if ( paramAndValue[0].equals(paramName) )
 return true;
 }
 return false;
 }
 
 The concern is whether this is valid should the URL have
 complex params 
 and such based on encoding schemes.  I mean, it just splits
 the url 
 query string into an array of param-values '',
 and then splits that by 
 '=' without concern for any encoding.
 
 David
 
 
Hi,

Wouldn't be faster/less coding if you just use this?

URL aURL = new URL(url);
String urlParams = aURL.getQuery();
if (urlParams.contains(paramName)) {
// proccess as needed if paramName exists
} else {
// process as otherwise
}

just a thought :)

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: directory structure

2009-09-12 Thread Tommy Pham
--- On Sat, 9/12/09, Daniel Blumenthal dan...@wordchamp.com wrote:

 From: Daniel Blumenthal dan...@wordchamp.com
 Subject: directory structure
 To: users@tomcat.apache.org
 Date: Saturday, September 12, 2009, 9:42 PM
 I'm reorganizing an existing project
 according to the generally accepted
 Java directory structure
 (http://java.sun.com/blueprints/code/projectconventions.html#23136),
 and
 everything seems to be working all right, but there's one
 thing I don't
 understand that seems like it should be a common problem
 with a common
 solution.  Currently, when I build a project for
 testing, it compiles the
 Java source, bundles everything into a .war, inserts it
 into the Tomcat
 webapps directory, and expands it.  However, in order
 to make a small change
 to a jsp file, css file, etc., I have to go through the
 entire build process
 again.
  
 I'd like to be able to set up a system in which I can make
 a change to a css
 file (or whatever) and see the change after reloading the
 page - i.e.,
 without having to run another build.

If you're referring to during the development phase, the IDEs I've worked with 
such as NetBeans and Eclipse does it for you automatically.  I don't remember 
if NetBeans actually make a war or not but it does autodeploy.  Eclipse will 
auto synchronize and sometimes it will auto-redeploy the app or restart TC 
depending on what was changed.  What IDE are you using?  If you're referring to 
production, isn't a bit a dangerous/risky to be doing changes as you mention?  
Production should be touched after thorough testing of the app on development 
server, correct me if I'm wrong.

Regards,
Tommy

  
 Is there a common way to do this?


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



Re: Loss of body POST request...

2009-09-15 Thread Tommy Pham
 Original Message 
 From: Eugene johnba...@gmail.com
 To: users@tomcat.apache.org
 Sent: Tuesday, September 15, 2009 3:30:02 AM
 Subject: Loss of body POST request...
 
 Hello. My next trouble. 
 Periodically, the body disappears POST-request with the same query! 
 I wrote a test client. It httpClient sends a test request, and on the server 
 side, the servlet it takes. And trying to read.
 Sometimes there is a situation that the titles are coming, but the body is 
 absent. 
 That is, when reading req.getInputStream (). Read (...) we obtain -1. 
 This error appears periodically. Tested on JBoss-4.2.2.GA with Tomcat 5.5.X. 
 Please, help me! 
 
 -- 
 Best Regards, Eugene Batogov

Time to implement Commons' FileUpload?

Regards,
Tommy

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


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



Re: Loss of body POST request...

2009-09-15 Thread Tommy Pham
- Original Message 
 From: Eugene johnba...@gmail.com
 To: Tomcat Users List users@tomcat.apache.org
 Sent: Tuesday, September 15, 2009 4:16:43 AM
 Subject: Re: Loss of body POST request...
 
 
 
 What has FileUpload, if the request body is lost! 
 I want to know why, in principle it may be lost?
 
 -- 
 Best Regards, Eugene Batogov
 ___

From my readings, I remember that the servlet doesn't handle POST by default.  
So you have to implement your own.  I've looked into options available and the 
best I could find, IMHO,  and others have suggested is Commons FileUpload.  It 
will handle all POST multipart, including the file upload.  Look into the 
Streams API.

Regards,
Tommy


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



Re: Loss of body POST request...

2009-09-15 Thread Tommy Pham
- Original Message 
 From: David Smith d...@cornell.edu
 To: Tomcat Users List users@tomcat.apache.org
 Sent: Tuesday, September 15, 2009 5:35:07 AM
 Subject: Re: Loss of body POST request...
 
 Servlets handle uri encoded POSTs just fine.  It's when the POST body is
 encoded differently like with mulipart -- that's where tools like
 fileupload come into the picture.  Either way, the POST body should be
 completely available to the servlet, even if it's just as an input stream. 
 
 Were there any exceptions in the logs for broken pipes or similar stuff
 that might shed some light on the issue?
 
 --David
 

Eugene,

Is the POST URI or multipart encoded?  You didn't mention it and I forgot to 
ask you.

Regards,
Tommy

 Tommy Pham wrote:
  - Original Message 
   
  From: Eugene 
  To: Tomcat Users List 
  Sent: Tuesday, September 15, 2009 4:16:43 AM
  Subject: Re: Loss of body POST request...
 
 
 
  What has FileUpload, if the request body is lost! 
  I want to know why, in principle it may be lost?
 
  -- 
  Best Regards, Eugene Batogov
  ___
 
 
  From my readings, I remember that the servlet doesn't handle POST by 
  default.  
 So you have to implement your own.  I've looked into options available and 
 the 
 best I could find, IMHO,  and others have suggested is Commons FileUpload.  
 It 
 will handle all POST multipart, including the file upload.  Look into the 
 Streams API.
 
  Regards,
  Tommy
 
   
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org


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



Re: php 5 and tomcat 6

2009-09-24 Thread Tommy Pham
- Original Message 
 From: Josh Gooding josh.good...@gmail.com
 To: Tomcat Users List users@tomcat.apache.org
 Sent: Thursday, September 24, 2009 7:06:11 AM
 Subject: php 5 and tomcat 6
 
 Hey gang,
 
 Does anyone know where the last release of PECL was that had the tomcat
 files in it for getting PHP to run with Tomcat?  Looks like the version of
 PHP I have (5.2.11) doesn't include the PECL libraries and from what I have
 read, the PECL are currently not released.  I seem to be coming up a bit
 short with the pecl.php.net as well since it doesn't include the dll pack
 for what I am looking for.
 
 TIA,
 
 Josh

Only way to get PHP running in Tomcat is through CGI.  There are serious 
security implications in this setup.  What you should do is setup PHP with 
Apache httpd and use a connector to communicate with Tomcat.  Perhaps you need 
to rethink why would you want to run PHP with Tomcat...  


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



[OT] Re: php 5 and tomcat 6

2009-09-24 Thread Tommy Pham
- Original Message 
 From: Hassan Schroeder hassan.schroe...@gmail.com
 To: Tomcat Users List users@tomcat.apache.org
 Sent: Thursday, September 24, 2009 10:36:19 AM
 Subject: Re: php 5 and tomcat 6
 
 On Thu, Sep 24, 2009 at 8:40 AM, Tommy Pham wrote:
 
  Only way to get PHP running in Tomcat is through CGI.
 
 Not true: http://quercus.caucho.com/
 
 -- 
 Hassan Schroeder  hassan.schroe...@gmail.com
 twitter: @hassan
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org

I think it maybe a problem with supporting full extensions from pecl/pear.


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



Re: UnsatisfiedLinkError in Windows Service (tomcat6w/5w.exe)

2009-01-20 Thread Tommy Pham




- Original Message 
From: Michael Ludwig mil...@gmx.de
To: Tomcat Users List users@tomcat.apache.org
Sent: Tuesday, January 20, 2009 4:55:16 PM
Subject: UnsatisfiedLinkError in Windows Service (tomcat6w/5w.exe)

A primitive web app sketch involving Java extensions to a native library
(JNI) used up front in a ServletContextListener works when started via
bin\startup.bat but doesn't work when installed as a Windows service and
started via bin\tomcat6w.exe in the case of 6.0.18 or bin\tomcat5w.exe
in the case of 5.5.27, on Windows XP.


Hi Michael,

I don't know if this is relevant to your problem or not and you didn't mention
whether you're x64 or x86 of XP version. I had problem of tomcat startup as 
service before on x64 (xp or Win03).  You need to replace the tomcat*.exe 
w/ the 64bit version.  The included *.exe are 32 bit.
Here's where you can get 64bit for tomcat5:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/procrun/bin/amd64/
and this is for tomcat6:
http://svn.apache.org/viewvc/tomcat/trunk/res/procrun/amd64/

Regards,
Tommy

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



Re: Slow servlet response under WinXP Pro

2009-03-30 Thread Tommy Pham

Hi Jon,


- Original Message 
 From: jo...@catholic-doc.org jo...@catholic-doc.org
 To: users@tomcat.apache.org
 Sent: Monday, March 30, 2009 11:45:37 AM
 Subject: Slow servlet response under WinXP Pro
 
 Hello!
 
 I am working on a servlet application.  It is a data entry application 
 that reads data from a Navision database, and writes data to MySQL.  Here 
 is the setup:
 
 WinXP Pro with Service Pack 3 (dev. box) / Windows 2003 Server (prod. box)
 Apache 2.2.11
 Tomcat 6.0.18
 MySQL 5.1.30
 MySQL Connector 5.1.7
 
 Driver for MySQL:  org.gjt.mm.mysql.Driver

Looking at the source for the connector, you might as well use the 
com.mysql.jdbc.Driver
since the org.gjt.mm.mysql.Driver just extends the com.mysql.jdbc.Driver.  I 
remember
reading somewhere that org.gjt.mm.mysql.Driver is for backward compatibility 
for older apps.
It will be phased out eventually.  You're recommended to use 
com.mysql.jdbc.Driver for
new application development.

 Driver for Navision: sun.jdbc.odbc.JdbcOdbcDriver
 
 There is no native JDBC driver for Navision, so I have to use the ODBC 
 version.
 
 I am having a problem with the time it takes to display a screen, when 
 there is database activity going on.  It can take anywhere from 30 seconds 
 to 90 seconds for the screen to appear.  This is not the time it takes 
 Tomcat to start up for the first time, it is long after that point.
 
 I think I may have found the problem, but I do not know how to fix it. All 
 of our systems (including the production server) have Symantec virus 
 software running.  When I turn the virus checking off, the application 
 runs very well, when I turn the virus checking on, I experience the slow 
 screen display.

From what you describe, this problem doesn't seem to be Tomcat related
since I use Win03 w/ Symantec Anti-Virus along with 3rd party firewall software.
Also, the Win03 is configured as a Domain Controller. I don't have this slow 
response you're reporting.  Your performance issue may lie with:

1) Fragmentation of your partition, especially the partition where the DB 
resides2) Size of your database
3) Configuration of MySQL 
4) Query is optimized (?)
5) Sufficient hardware to handle the DB size (?)

Regards,
Tommy

 I googled for conflicts of Tomcat with virus scanning software, and only 
 found reference to the fact that it can cause performance problems.  But, 
 I could not find a solution, other than turning off the virus scanning. 
 Does anyone know of a solution to this problem?  I have been told that 
 turning off the virus scanning on the production box is not an option.  I 
 have also been told that Linux is not an option. 
 
 I have gone through the Symantec software, and can not find a way to 
 exclude Tomcat, etc. from its process.  Where do I go from here?
 
 Thanks,
 
 Jon Oman


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



Re: Slow servlet response under WinXP Pro

2009-03-30 Thread Tommy Pham





- Original Message 
 From: Tommy Pham tommy...@yahoo.com
 To: Tomcat Users List users@tomcat.apache.org
 Sent: Monday, March 30, 2009 12:23:54 PM
 Subject: Re: Slow servlet response under WinXP Pro
 
 Hi Jon,
 
 
 - Original Message 
  From: jo...@catholic-doc.org 
  To: users@tomcat.apache.org
  Sent: Monday, March 30, 2009 11:45:37 AM
  Subject: Slow servlet response under WinXP Pro
  
  Hello!
  
  I am working on a servlet application.  It is a data entry application 
  that reads data from a Navision database, and writes data to MySQL.  Here 
  is the setup:
  
  WinXP Pro with Service Pack 3 (dev. box) / Windows 2003 Server (prod. box)
  Apache 2.2.11
  Tomcat 6.0.18
  MySQL 5.1.30
  MySQL Connector 5.1.7
  
  Driver for MySQL:  org.gjt.mm.mysql.Driver
 
 Looking at the source for the connector, you might as well use the 
 com.mysql.jdbc.Driver
 since the org.gjt.mm.mysql.Driver just extends the com.mysql.jdbc.Driver.  I 
 remember
 reading somewhere that org.gjt.mm.mysql.Driver is for backward compatibility 
 for 
 older apps.
 It will be phased out eventually.  You're recommended to use 
 com.mysql.jdbc.Driver for
 new application development.
 
  Driver for Navision: sun.jdbc.odbc.JdbcOdbcDriver
  
  There is no native JDBC driver for Navision, so I have to use the ODBC 
  version.
  
  I am having a problem with the time it takes to display a screen, when 
  there is database activity going on.  It can take anywhere from 30 seconds 
  to 90 seconds for the screen to appear.  This is not the time it takes 
  Tomcat to start up for the first time, it is long after that point.
  
  I think I may have found the problem, but I do not know how to fix it. All 
  of our systems (including the production server) have Symantec virus 
  software running.  When I turn the virus checking off, the application 
  runs very well, when I turn the virus checking on, I experience the slow 
  screen display.
 
 From what you describe, this problem doesn't seem to be Tomcat related
 since I use Win03 w/ Symantec Anti-Virus along with 3rd party firewall 
 software.
 Also, the Win03 is configured as a Domain Controller. I don't have this slow 
 response you're reporting.  Your performance issue may lie with:
 
 1) Fragmentation of your partition, especially the partition where the DB 
 resides2) Size of your database
 3) Configuration of MySQL 
 4) Query is optimized (?)
 5) Sufficient hardware to handle the DB size (?)

forgot 1 more :)
 6) SAV configuration


 Regards,
 Tommy
 
  I googled for conflicts of Tomcat with virus scanning software, and only 
  found reference to the fact that it can cause performance problems.  But, 
  I could not find a solution, other than turning off the virus scanning. 
  Does anyone know of a solution to this problem?  I have been told that 
  turning off the virus scanning on the production box is not an option.  I 
  have also been told that Linux is not an option. 
  
  I have gone through the Symantec software, and can not find a way to 
  exclude Tomcat, etc. from its process.  Where do I go from here?
  
  Thanks,
  
  Jon Oman


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



Iterate LinkedHashMap gives HTTP 500 in a JSP (NPE)

2009-04-19 Thread Tommy Pham

Hi,

I have a problem iterating a LinkedHashMapInteger, Object lhmObject. 
The lhmObject.size() gives correct size and lhmObject.keySet().toString gives 
the correct values.
However, if I try iterate the object with lhmObject.keySet() with an empty loop:

for (Integer key : lhmObject.keySet() ) { }

or

for (Iterator it = lhmObject.keySet().iterator(); it.hasNext(); ) { }

I get a HTTP 500 - NullPointerException in the JSP page, which has java.util.* 
and appropriate package.Object for import.
Has anyone seen this before?

Tomcat 6.0.18
JDK 1.6u4
Win03R2 x86

TIA,
Tommy

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



Eclipse builtin browser vs system default browser problem

2009-08-19 Thread Tommy Pham
Hi,

I'm working a small project seem to run into a snag and can't figure out how to 
overcome it since my web app doesn't give any exception (log files are clean 
are error/exception free).  The snag is that the eclipse internal web browser 
shows the desired result while Firefox doesn't...  Here's the SS of my problem:
http://img40.imageshack.us/img40/8029/languages.jpg

Has anyone seen something like this before? I was trying to use FF's 
LiveHeaders extension to work on form's POST multipart/form-data. Below is my 
dev environment:

OS: Win2008 x64
JDK: jdk1.6.0_14 x64
Tomcat: 6.0.20
Eclipse: 3.4.2 (updated)

Libs for web app project:
Hibernate3-core 3.3.2 GA (using Tomcat's context datasource)
JSTL1.2
Commons FileUpload 1.2.1
Log4j 1.2.15
DWR 3.0.0.116.rc1 (yet to be implemented - jar is in WEB-INF/lib)

TIA,
Tommy


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



Re: Eclipse builtin browser vs system default browser problem

2009-08-20 Thread Tommy Pham




- Original Message 
 From: Martin Gainty mgai...@hotmail.com
 To: Tomcat Users List users@tomcat.apache.org
 Sent: Wednesday, August 19, 2009 4:09:28 PM
 Subject: RE: Eclipse builtin browser vs system default browser problem
 
 
 run FF firebug-plugin and view the DOM on both screens and note the deltas
 http://joehewitt.com/software/firebug/
 
 view the Request details for both and note the deltas
 what do the logs say for server?
 
 Martin Gainty 
 __ 
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
 sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
 oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich 
 dem 
 Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
 Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
 fuer den Inhalt uebernehmen.
 Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
 destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
 l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci 
 est 
 interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
 quel effet légalement obligatoire. Étant donné que les email peuvent 
 facilement 
 être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
 pour le contenu fourni.
 
 
 
 
  Date: Wed, 19 Aug 2009 15:26:08 -0700
  From: tommy...@yahoo.com
  Subject: Eclipse builtin browser vs system default browser problem
  To: users@tomcat.apache.org
  
  Hi,
  
  I'm working a small project seem to run into a snag and can't figure out 
  how 
 to overcome it since my web app doesn't give any exception (log files are 
 clean 
 are error/exception free).  The snag is that the eclipse internal web browser 
 shows the desired result while Firefox doesn't...  Here's the SS of my 
 problem:
  http://img40.imageshack.us/img40/8029/languages.jpg
  
  Has anyone seen something like this before? I was trying to use FF's 
 LiveHeaders extension to work on form's POST multipart/form-data. Below is my 
 dev environment:
  
  OS: Win2008 x64
  JDK: jdk1.6.0_14 x64
  Tomcat: 6.0.20
  Eclipse: 3.4.2 (updated)
  
  Libs for web app project:
  Hibernate3-core 3.3.2 GA (using Tomcat's context datasource)
  JSTL1.2
  Commons FileUpload 1.2.1
  Log4j 1.2.15
  DWR 3.0.0.116.rc1 (yet to be implemented - jar is in WEB-INF/lib)
  
  TIA,
  Tommy
  
  
  -
  To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
  For additional commands, e-mail: users-h...@tomcat.apache.org
  
 

Sorry folks, my mistake :)  After short break and a review line by line of my 
source code, it turned out that I wasn't handling my session correctly :)  It's 
been a very long week for me.

Thanks,
Tommy


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



[OT] multipart/form-data solutions

2009-08-21 Thread Tommy Pham

Hi,

I need some to process some multipart/form-data.  Are the any other solutions 
other 
than:

Solution A:

1. download http://www.servlets.com/cos/index.html
2. invoke getParameters() on com.oreilly.servlet.MultipartRequest

Solution B:

1. download http://jakarta.apache.org/commons/sandbox/fileupload/
2. invoke readHeaders() in 
org.apache.commons.fileupload.MultipartStream

Solution C:

1. download http://users.boone.net/wbrameld/multipartformdata/
2. invoke getParameter on 
com.bigfoot.bugar.servlet.http.MultipartFormData

Solution D:

frameworks like struts, jsf, etc..


TIA,
Tommy


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



Re: [OT] multipart/form-data solutions

2009-08-22 Thread Tommy Pham

- Original Message 
 From: Pid p...@pidster.com
 To: Tomcat Users List users@tomcat.apache.org
 Sent: Saturday, August 22, 2009 4:04:32 AM
 Subject: Re: [OT] multipart/form-data solutions
 
 On 22/08/2009 06:11, Tommy Pham wrote:
 
  Hi,
 
  I need some to process some multipart/form-data.  Are the any other 
  solutions 
 other
  than:
 
 What are you really trying to achieve?  Are you uploading a file, or 
 doing something else?
 

Hi Pid,

Thanks for the reply.  I want to process a multipart/form-data form submitted 
from the client via POST method.  The form may also or may not have a file 
upload.  I thought if there are any other solutions/methods than what I've 
found so far.

  Solution A:
 
  1. download http://www.servlets.com/cos/index.html
  2. invoke getParameters() on com.oreilly.servlet.MultipartRequest
 
  Solution B:
 
  1. download http://jakarta.apache.org/commons/sandbox/fileupload/
  2. invoke readHeaders() in
  org.apache.commons.fileupload.MultipartStream
 
 I don't know about the other examples, but the above looks like an out 
 of date reference.  http://commons.apache.org/fileupload/ is the current 
 version.
 
 Without knowing what you're really trying to achieve, it's hard to say, 
 but readHeaders() doesn't seem like the right method to call.
 
 p
 

Yes, silly me for just copying and pasting without checking first :)  I also 
tried MultipartStream.readHeaders() method found on the web but the coding 
wasn't elegant (perhaps it was based on the older version of FileUpload since 
the guide is a few years old).  After going through the sample guides on 
Apache's FileUpload site and
going through every class in the JavaDoc, I found the solution to my
problem. The streaming API guide on the home site is very nice and easy to 
implement using ServletFileUpload.parseRequest().

Thanks,
Tommy

 
  Solution C:
 
  1. download http://users.boone.net/wbrameld/multipartformdata/
  2. invoke getParameter on
  com.bigfoot.bugar.servlet.http.MultipartFormData
 
  Solution D:
 
  frameworks like struts, jsf, etc..
 
 
  TIA,
  Tommy
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
  For additional commands, e-mail: users-h...@tomcat.apache.org
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org


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



RE: tomcat 6 (windows 7- 64 bits) doesn't start

2010-05-07 Thread Tommy Pham
 -Original Message-
 From: Christoph Kukulies [mailto:k...@kukulies.org]
 Sent: Friday, May 07, 2010 12:21 AM
 To: Tomcat Users List
 Cc: Caldarale, Charles R
 Subject: Re: tomcat 6 (windows 7- 64 bits) doesn't start
 
 Am 06.05.2010 14:51, schrieb Caldarale, Charles R:
  From: Christoph Kukulies [mailto:k...@kukulies.org]
  Subject: Re: tomcat 6 (windows 7- 64 bits) doesn't start
 
  I believe it's because I only have the jre, not the jdk and I'm
  downloading at the moment.
 
  No, Tomcat runs fine on a JRE.  The problem is that you have a 32-bit
JVM
 installed in a 64-bit OS.  (The 32-bit Windows JVM has only the client
DLL, the
 64-bit only the server DLL.)  The Tomcat installer program expects the JVM
 mode to match that of the OS.  Use a 64-bit JVM.
 
- Chuck
 
 Thanks. That's correct what you are saying. But this also means that
 whenever you're  asked to download the latest Java from java.com
 (Sun/Oracle) with whatever Java app, e.g. OpenOffice or something, that
 infamous installer that always installs the Yahoo toolbar in your browser
 when you don't untick that checkbox, you always get the 32bit version JVM
 on windows.
 
 I looked for a 64bit version on their download page to no avail.
 
 --
 Christoph Kukulies
 
 

Christoph,

Try java.sun.com.  Specifically:
http://java.sun.com/javase/downloads/widget/jdk6.jsp

Regards,
Tommy


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



RE: tomcat 6 (windows 7- 64 bits) doesn't start

2010-05-07 Thread Tommy Pham
 -Original Message-
 From: Karthick Ragunath [mailto:karthick.ragun...@live.com]
 Sent: Friday, May 07, 2010 7:01 AM
 To: users@tomcat.apache.org
 Subject: RE: tomcat 6 (windows 7- 64 bits) doesn't start
 
 
 Yeah,,
  well Charles
 
  Windows 7 64 bit OS, when installing Tomcat, expects for 64This version
of
 JVM's dll located at C:\Program
 Files\Java\jdk1.6.0_12\jre\bin\server\jvm.dll
 
  The problem now is that, i do not want to install Java twice (one 32-bit
and
 other 64-bit) as how i have done it now.  Some other applications using
Java
 requires 32bit always. (Eclipse requires 32 bit JVM which otherwise would
 result in JVM termination error during Eclipse startup).
 
 I have downloaded latest Tomcat windows Installable.
 
 This same Tomcat installable, when installed in 32bit XP where 32bit JVM
is
 installed, gets installed properly, but not with Windows 7 64 prof.
 
 Is there an alternate solution for this. I would be happy to use the 32bit
JVM .
 Not many applications are supported by 64 bit JVM.
 
 
 
 with regards
 karthick
 

Karthick,

You can run Tomcat with 32 bit JVM on 64 bit Windows.  Uninstall the current
Tomcat service you have.  Set the JAVA_HOME environment in the System
Variables to the proper location and reboot.  Download Tomcat, the 32 bit
version of Windows zip file, and install the service via the batch file.
 
Regards,
Tommy

 
  From: chuck.caldar...@unisys.com
  To: users@tomcat.apache.org
  Date: Thu, 6 May 2010 07:51:06 -0500
  Subject: RE: tomcat 6 (windows 7-  64 bits) doesn't start
 
   From: Christoph Kukulies [mailto:k...@kukulies.org]
   Subject: Re: tomcat 6 (windows 7- 64 bits) doesn't start
  
   I believe it's because I only have the jre, not the jdk and I'm
   downloading at the moment.
 
  No, Tomcat runs fine on a JRE.  The problem is that you have a 32-bit
JVM
 installed in a 64-bit OS.  (The 32-bit Windows JVM has only the client
DLL, the
 64-bit only the server DLL.)  The Tomcat installer program expects the JVM
 mode to match that of the OS.  Use a 64-bit JVM.
 
   - Chuck
 
 
  THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR
 OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended
 recipient. If you received this in error, please contact the sender and
delete
 the e-mail and its attachments from all computers.
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
  For additional commands, e-mail: users-h...@tomcat.apache.org
 
 
 __
 ___
 Catch the latest in the world of fashion http://lifestyle.in.msn.com/


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



RE: tomcat 6 (windows 7- 64 bits) doesn't start

2010-05-08 Thread Tommy Pham
 -Original Message-
 From: Karthick Ragunath [mailto:karthick.ragun...@live.com]
 Sent: Saturday, May 08, 2010 1:52 AM
 To: users@tomcat.apache.org
 Subject: RE: tomcat 6 (windows 7- 64 bits) doesn't start
 
 
  From: tommy...@gmail.com
  To: users@tomcat.apache.org
  Subject: RE: tomcat 6 (windows 7-  64 bits) doesn't start
  Date: Fri, 7 May 2010 18:34:03 -0700
 
  Karthick,
 
  You can run Tomcat with 32 bit JVM on 64 bit Windows.  Uninstall the
  current Tomcat service you have.  Set the JAVA_HOME environment in the
  System Variables to the proper location and reboot.  Download Tomcat,
  the 32 bit version of Windows zip file, and install the service via the
batch
 file.
 
 Thanks,,
 
  I got Tomcat working with 32-bit JVM.(with additional work as
mentioned
 below)
 
  Installed 32-bit JVM, downloaded apache-tomcat-6.0.26-windows-x86.zip
 and extracted to c:\apache\.
 
  I tried running the $CATALINA_HOME\bin\startup.bat. It started the
 console and i was able to access the index page on my localhost
 
  But when i tried to register Tomcat as Service by running
service.bat it
 failed.
 Copying msvcr71.dll from $JRE_HOME\jre6\bin into
 $CATALINA_HOME\bin\ solved my problem. Now i can register Tomcat as a
 Service by clicking on service.bat.
 
  Any idea on why i am in need of this dll here..
 
 warm regards
 karthick
 
 __
 ___
 The amazing world in sharp snaps
 http://news.in.msn.com/gallery/archive.aspx

I just install all the current VS (2005 sp1 to 2010) redistributables (both
x86 and x64) to solve any missing DLLs problems in Windows.  As for need for
DLL by Tomcat, I think it's the way the EXE was compiled (dynamically
linked).

Regards,
Tommy


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



RE: tomcat 6 (windows 7- 64 bits) doesn't start

2010-05-08 Thread Tommy Pham
 -Original Message-
 From: Mladen Turk [mailto:mt...@apache.org]
 Sent: Saturday, May 08, 2010 2:59 AM
 To: users@tomcat.apache.org
 Subject: Re: tomcat 6 (windows 7- 64 bits) doesn't start
 
 On 05/08/2010 11:32 AM, Tommy Pham wrote:
  -Original Message-
 
  I just install all the current VS (2005 sp1 to 2010) redistributables
  (both
  x86 and x64) to solve any missing DLLs problems in Windows.  As for
  need for DLL by Tomcat, I think it's the way the EXE was compiled
  (dynamically linked).
 
 
 It has nothing to do with tomcat. The missing .dll is JVM dependency.
 The copy can be avoided by setting up the system PATH to include the JRE
 bin folder (usually reboot will be required)
 
 It is something Sun refuses to handle and ships the msvcrt71.dll as part
of
 their dist instead to follow the Windows Logo guidelines and install the
 MSVCRT runtime separately.
 
 
 Regards
 --
 ^TM
 

Thanks for setting me straight.

Regards,
Tommy


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



[OT] Tomcat on Linux

2010-09-15 Thread Tommy Pham
Hi,

I was wondering what flavor(s) of Linux, if applicable, do you use to
develop? And what Linux flavor(s) do you have Tomcat running production on?

Thanks,
Tommy


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



RE: [OT] Tomcat on Linux

2010-09-20 Thread Tommy Pham
Thanks everyone for your input.  I was hoping to get a better understanding of 
the differences between the flavors of Linux and how well and easy for me to 
run Tomcat.  I guess I'll have to spend more time on various flavors.

Thanks again,
Tommy


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



HTTP 500.0 on IIS7.5 + JK1.2.36 + TC7.0.26

2012-05-14 Thread Tommy Pham
Hi,

I'm trying to get the connector (JK 1.2.36) to work for IIS7.5
(Windows 7 Enterprise) but keep on running into HTTP 500.0 Error
following the documentation [1]:

Error Summary

HTTP Error 500.0 - Internal Server Error
Calling GetFilterVersion on ISAPI filter
D:\apache-tomcat-7.0.26\bin\connector\isapi_redirect.dll failed

Detailed Error Information

Module  IIS Web Core
NotificationUnknown
Handler ExtensionlessUrlHandler-Integrated-4.0
Error Code  0x8007047e
Requested URL   http://localhost:80/
Physical Path   E:\wwwroot
Logon MethodNot yet determined
Logon User  Not yet determined



Here are my configurations:

[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi
Redirector\1.0]
extension_uri=/jakarta/isapi_redirect.dll
log_file=D:\\apache-tomcat-7.0.26\\logs\\isapi.log
log_level=info
worker_file=D:\\apache-tomcat-7.0.26\\conf\\workers.properties
woker_mount_file=D:\\apache-tomcat-7.0.26\\conf\\uriworkermap.properties

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W3SVC\Parameters\Filter
DLLS]
@=D:\\apache-tomcat-7.0.26\\bin\\connector

# workers.properties
# An entry that lists all the workers defined
worker.list=localworker
# Entries that define the host and port associated with each of these workers
worker.localworker.host=localhost
worker.localworker.port=8009
worker.localworker.type=ajp13
#worker.worker2.host=otherhost
#worker.worker2.port=8009
#worker.worker2.type=ajp13

# uriworkermap.properties
/examples = localworker

D:\apache-tomcat-7.0.26\bin\connector is mapped as an application
virtual directory /jakarta using ASP.NET v4 integrated application
pool (I've tried the 3 other pools - v4 classic, v2 integrated, and v2
classic - and also failed).  The application pool is configured to run
under Network Service account.  The Network Service account has read 
execute permissions on the folder D:\apache-tomcat-7.0.26 recursively
and write permissions on the D:\apache-tomcat-7.0.26\logs folder.

ISAPI-dll handler mapping, with feature permissions of Read, Script 
Execute, has:
1) *.dll for Request path
2) Executable of D:\apache-tomcat-7.0.26\bin\connector\isapi_redirect.dll
3) Request Restrictions
   a) Mapping  Invoke handler only if request is mapped to:
 File or folder
   b) Verbs  All verbs
   c) Access  Execute

ISAPI and CGI Restrictions allows the said
D:\apache-tomcat-7.0.26\bin\connector\isapi_redirect.dll.

ISAPI Filters has an entry for the
D:\apache-tomcat-7.0.26\bin\connector\isapi_redirect.dll.


My Google-fu isn't very helpful ATM.  Am I missing something?  BTW, I
also have URLScan filter loaded.  Would that interfere with JK
connector?


Thanks,
Tommy


[1] http://tomcat.apache.org/connectors-doc/webserver_howto/iis.html

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



Re: HTTP 500.0 on IIS7.5 + JK1.2.36 + TC7.0.26

2012-05-15 Thread Tommy Pham
On Mon, May 14, 2012 at 11:17 PM, Mladen Turk mt...@apache.org wrote:
 On 05/15/2012 07:58 AM, Tommy Pham wrote:

 Hi,

 I'm trying to get the connector (JK 1.2.36) to work for IIS7.5
 (Windows 7 Enterprise) but keep on running into HTTP 500.0 Error
 following the documentation [1]:

 Error Summary

 HTTP Error 500.0 - Internal Server Error
 Calling GetFilterVersion on ISAPI filter


 D:\apache-tomcat-7.0.26\bin\connector\isapi_redirect.dll failed

 log_file=D:\\apache-tomcat-7.0.26\\logs\\isapi.log
 log_level=info


 Is there anything written to that log file?

No, the log file isapi.log never got created.  Only logs I see are
Tomcat's:  catalina*.log, commons-daemon*.log, host-manager*.log,
localhost*.log, localhost_access_log*.txt, manager*.log,
tomcat7-stderr*.log.

 If not, I'd suggest fixing security for D:\apache-tomcat-7.0.26 logs
 and bin folders. IIS runs under special account and it might
 not have read/write permissions to that folder.

By default, IIS 7.5's' application pools are configured to run as
ApplicationPoolIdentity.  I've changed it to the NetworkService
account, which has read, list, and execute permissions on Tomcat's
home directory and recursively, in addition to write/modify
permissions on Tomcat's logs directory.

 Also, why Win7? That's workstation, so unless you are experimenting
 make no sense to use that for anything except serving few clients.
 There is a hard limit on number of connections you can use on any
 workstation-kind of windows.

It's a laptop and used as a portable development/testing system.  Yes,
I'm aware of the limitations of Windows workstations (max 10
connections, etc...).



 Regards
 --
 ^TM


Thanks for the reply,
Tommy

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



Re: Tomcat 7.0.x, Windows 7 x64 professional - question

2012-08-08 Thread Tommy Pham
On Tue, Aug 7, 2012 at 7:58 PM, Christopher Schultz
ch...@christopherschultz.net wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Ken,

 On 8/7/12 12:01 PM, Ken Alverson wrote:
 We are trying to get our application Microsoft certified.

 Forgive my ignorance, but what the heck does a Microsoft certified
 application mean?

 There are several test cases that involve adding digital
 signatures, required manifest entries, etc. that do not currently
 exist for Tomcat exe's. I am just wondering if anyone else has run
 into trouble getting certified with Microsoft using Tomcat?

 Is it even possible to get a Java-based program certified by Microsoft
 in any way? I would have thought that you'd have to use Silverli...,
 er, .NE..., er ... I guess Metro is this year's standard technology.


Isn't rather interesting that the product's been in development and
trying to pick up momentum for years only to get shot down before
launch.


http://www.bbc.co.uk/news/technology-19108952

 - -chris
 -BEGIN PGP SIGNATURE-
 Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
 Comment: GPGTools - http://gpgtools.org
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iEYEARECAAYFAlAh1ccACgkQ9CaO5/Lv0PA/PACeJk5P9CrLEJglbaAn0/dxT8P6
 jmYAoMBYCVad2R7+kz4k34N9XlHsc2Qw
 =4Z9m
 -END PGP SIGNATURE-


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



virtual directory

2013-03-21 Thread Tommy Pham
Hi,

I'm trying to setup my virtual directory wwwroot as
http://localhost/wwwroot/ mapped to d:\wwwroot but I'm getting

HTTP Status 404 - /wwwroot/

type Status report

message /wwwroot/

description The requested resource (/wwwroot/) is not available.
Apache Tomcat/7.0.26



My wwwroot.xml:

?xml version=1.0 encoding=ISO-8859-1?
Context path=/wwwroot docBase=D:/wwwroot debug=0 privileged=true
/Context

and the localhost log:

Mar 21, 2013 10:14:38 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Mar 21, 2013 10:14:38 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor
D:\apache-tomcat-7.0.26\conf\Catalina\localhost\wwwroot.xml
Mar 21, 2013 10:14:38 AM
org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'debug'
to '0' did not find a matching property.
Mar 21, 2013 10:14:39 AM org.apache.catalina.util.SessionIdGenerator
createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation
using [SHA1PRNG] took [145] milliseconds.
Mar 21, 2013 10:14:39 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.26\webapps\docs

Did I misread the doc [1]?

Thanks,
Tommy

[1] http://tomcat.apache.org/tomcat-7.0-doc/config/context.html

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



Re: virtual directory

2013-03-21 Thread Tommy Pham
On Thu, Mar 21, 2013 at 11:10 AM, André Warnier a...@ice-sa.com wrote:
 Manuel Fernández Panzuela wrote:

 To publish your wwwdoc directory you must edit sever.xml and look for
 Host
 tag. Inside this block write a line like::

 Context docBase=D:/wwwroot path=/wwwroot reloadable=true /

 Hi.
 Don't top-post.
 And the page which the original poster apparently mis-read, also says (in
 bold) :

 It is NOT recommended to place Context elements directly in the server.xml
 file.

 https://tomcat.apache.org/tomcat-7.0-doc/config/context.html



Hi André,

Thanks for the feedback.  I'm still getting the 404 error with this wwwroot.xml:

?xml version=1.0 encoding=ISO-8859-1?
Context docBase=D:/wwwroot
/Context

And the catalina log shows:Mar 21, 2013 11:46:27 AM

org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Mar 21, 2013 11:46:27 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor
D:\apache-tomcat-7.0.26\conf\Catalina\localhost\wwwroot.xml
Mar 21, 2013 11:46:28 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.26\webapps\docs
Mar 21, 2013 11:46:28 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory
D:\apache-tomcat-7.0.26\webapps\examples

Thanks,
Tommy

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



Re: virtual directory

2013-03-21 Thread Tommy Pham
Hi Chuck and Andre,

Silly me... I figured out what was the issue.  I didn't have the index
page defined in Tomcat's web.xml within the D:\wwwroot.  The eventual
content of this folder will be images anyway.  Would I need to code an
interceptor to detect 404 error and path to redirect the visitor to
another URL instead of Tomcat's default 404 error?

Thanks for your time,
Tommy

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



Tomcat embedded deprecated

2014-02-10 Thread Tommy Pham
Hi folks,

I'm seeing:

@Deprecated 
http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true
public class Embedded

at doc site [1] which I presume that the embedded is removed in 8.x?  Could
someone please explain why it's deprecated or point me in the right
direction of why it's deprecated?


Thanks,
Tommy


[1]
http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/startup/Embedded.html


Re: Tomcat embedded deprecated

2014-02-10 Thread Tommy Pham
Thanks Gary and Violeta for the responses.  Mark's presentation was what
I'm looking for.

Kind regards,
Tommy


On Mon, Feb 10, 2014 at 9:40 AM, Violeta Georgieva miles...@gmail.comwrote:

 Hi,


 2014-02-10 Tommy Pham tommy...@gmail.com:
 
  Hi folks,
 
  I'm seeing:
 
  @Deprecated 

 http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true
 
  public class Embedded
 
  at doc site [1] which I presume that the embedded is removed in 8.x?
  Could
  someone please explain why it's deprecated or point me in the right
  direction of why it's deprecated?

 It is there:

 Deprecated.
 Use Tomcat instead.
 [1]

 Checke this presentation [2]. It's a good starting point.


 Regards
 Violeta

 [1]

 http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/startup/Tomcat.html
 [2]

 http://people.apache.org/~markt/presentations/2010-11-04-Embedding-Tomcat.pdf



restriction/limit of keystorePass in server.xml for TC7

2015-07-23 Thread Tommy Pham
Hi everyone,

I know this maybe more of Java than Tomcat but in case it's coded
somewhere... Anyway, is there a limit to number of characters (30 - 50) and
limit to certain characters, symbols included, for the keystorePass?  I
only thing I can find for keystorePass limit tomcat 7 are how to setup
SSL and enable TLSes only.  I know some of you are thinking why 30+ when
the password is in plain text file...

TIA,
Tommy


Re: Encrypted jdbc

2016-04-07 Thread Tommy Pham
Perhaps trying asking the MariaDB forum/list?

On Thu, Apr 7, 2016 at 7:08 AM, Linux Support  wrote:

> Greetings all,
>
> =
> Server number:  8.0.28.0
> OS Name:Linux
> OS Version: 2.6.32-573.8.1.el6.x86_64
> JVM Version:1.8.0_66-b17
> =
>
> Back end database is mariadb residing on a another remote linux instance. I
> have downloaded and copied the Mariadb jdbc driver to the lib directory of
> the TC server.
>
> Can you let me know how to encrypt the database connectivity from the TC
> instance to the DB instance.
>
> thanks
> OSP
>


TC 9.0.21: ContextListener + Servlet app

2019-06-14 Thread Tommy Pham
Hello everyone,

I'm trying to write a lightweight and hopefully simple ContextListener +
Servlet application but running into 2 issues I'm unable to find resolution
for and hoping someone would please point me in the right direction:

1)  I'd like to have Tomcat's default servlet serve HTML files only within
directory /path/ and its' subdirectories.  However, I can only get it to
work with this URL mapping "/path/*".  My understanding is that the default
servlet will serve any files within /path/.  Can this be done with URL path
mapping or do I need to write a custom filter?  My servlet's mapping is
"/".  Tomcat's default servlet mapping has "/css/*", "/js/*", "/img/*", and
"/path/*".

2)  I Have this small and simple HTML form:

  
  

My servlet's doPost is triggered but when I iterate the
request.getParameterMap(), it's empty.  When I tried to
request.getParameter("text"), it returned 'null'.  I do have a filter in
place but it's only to log all request access to a database backend
eventually.  That filter is currently dumping it to log.  I've tried
disabling the filter but have the same result.

Thank you,
Tommy


Re: TC 9.0.21: ContextListener + Servlet app

2019-06-14 Thread Tommy Pham
Hi Mark,

Thanks for the prompt reply.  I'll try with Filter for (1).  I figured out
what I did wrong with (2).  I was missing the HTML attribute 'name' for the
text input.  It's been a couple years since I've wrote a HTML page.

Thanks again for your help,
Tommy

On Fri, Jun 14, 2019 at 1:48 PM Mark Thomas  wrote:

> On 14/06/2019 21:10, Tommy Pham wrote:
> > Hello everyone,
> >
> > I'm trying to write a lightweight and hopefully simple ContextListener +
> > Servlet application but running into 2 issues I'm unable to find
> resolution
> > for and hoping someone would please point me in the right direction:
> >
> > 1)  I'd like to have Tomcat's default servlet serve HTML files only
> within
> > directory /path/ and its' subdirectories.  However, I can only get it to
> > work with this URL mapping "/path/*".  My understanding is that the
> default
> > servlet will serve any files within /path/.  Can this be done with URL
> path
> > mapping or do I need to write a custom filter?  My servlet's mapping is
> > "/".  Tomcat's default servlet mapping has "/css/*", "/js/*", "/img/*",
> and
> > "/path/*".
>
> It depends. If there are alternative mappings (with a higher priority)
> for all the other static files under /path/* then the DefaultServlet
> will only serve what is left.
>
> A filter might be the cleanest way to ensure you get the behaviour you
> want.
>
> > 2)  I Have this small and simple HTML form:
> > 
> >   
> >   
> > 
> > My servlet's doPost is triggered but when I iterate the
> > request.getParameterMap(), it's empty.  When I tried to
> > request.getParameter("text"), it returned 'null'.  I do have a filter in
> > place but it's only to log all request access to a database backend
> > eventually.  That filter is currently dumping it to log.  I've tried
> > disabling the filter but have the same result.
>
> You need:
> 
>
> Mark
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Tomcat embedded

2019-06-16 Thread Tommy Pham
Hello everyone,

1) Is there an official documentation for embedding TC process?  My search
shows various how-to on other sites.
   a)  If not, I guess I could request to be added to the wiki to
contribute one.  Since I don't quite know all the details of TC, is there a
review process to ensure clarity and complete coverage of embedding process?

2) (probably better to ask the dev list?) I noticed there are some
differences in the official binary distribution vs development environment:
   a)  Official has annotations-api.jar while development has according to
gradle:

default - Configuration for default artifacts.
+--- org.apache.tomcat.embed:tomcat-embed-core:9.0.+ -> 9.0.21
|\--- org.apache.tomcat:tomcat-annotations-api:9.0.21

while the jar file names are different, the classes' name and the jar's
manifest within appear to the same.  I think this is trivial.
   b)  ecj version differences:  the official binary uses ecj-4.10.jar
while the development, per gradle, uses ecj-3.16:

default - Configuration for default artifacts.
+--- org.apache.tomcat.embed:tomcat-embed-jasper:9.0.+ -> 9.0.21
|+--- org.apache.tomcat.embed:tomcat-embed-core:9.0.21 (*)
|+--- org.apache.tomcat.embed:tomcat-embed-el:9.0.21
|\--- org.eclipse.jdt:ecj:3.16.0

Is there a particular reason while such big difference of the major version
4.x vs 3.x?  According to the tomcat-embed maven repository [1]:


org.eclipse.jdt
ecj
3.16.0


Thanks,
Tommy

[1]
http://repo2.maven.org/maven2/org/apache/tomcat/embed/tomcat-embed-jasper/9.0.21/tomcat-embed-jasper-9.0.21.pom


Re: TC 9.0.21: ContextListener + Servlet app

2019-06-20 Thread Tommy Pham
Hi Mark,


On Sun, Jun 16, 2019 at 2:25 AM Tommy Pham  wrote:

> Hi Chris,
>
> Thank you for the feedback.
>
> On Sat, Jun 15, 2019 at 10:44 PM Christopher Schultz <
> ch...@christopherschultz.net> wrote:
>
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA256
>>
>> Tommy,
>>
>> On 6/15/19 21:51, Tommy Pham wrote:
>> > Hi Mark,
>> >
>> > After some research and thought about internal application flow, I
>> > think the 'cleanest' is have TC's default servlet handle the *.html
>> > requests and use the assigned filter to restrict the access as
>> > desired.  Is there a better approach?  On that plan, I have this
>> > mapping for TC's default servlet and init:
>> >
>> > Filter AppFilterAccessLog's servlet mapping: Servlet name: default
>> > , registered class: org.apache.catalina.servlets.DefaultServlet.
>> > Servlet default's mapping: /img/* /css/* /WEB-INF/*
>>
>> Uh... you sure you want that? What is stopping a client from requesting
>> /WEB-INF/web.xml?
>>
>> > /js/* Servlet default's init parameters: listings: false debug: 0
>> >
>> > If I use *.html instead of /WEB-INF/*, it goes into infinite loop
>> > redirecting / forwarding until exception is thrown (I think that
>> > root cause is servlets' startup ordering).  Below are what my
>> > access log filter see for HttpServletRequest:
>> >
>> > Attributes: javax.servlet.forward.request_uri=/erm-0.0.1-SNAPSHOT/
>> > javax.servlet.forward.context_path=/erm-0.0.1-SNAPSHOT
>> > javax.servlet.forward.servlet_path=
>> > javax.servlet.forward.path_info=/
>> >
>> > javax.servlet.forward.mapping=org.apache.catalina.core.ApplicationMapp
>> ing$MappingImpl@7fc1f887
>> >
>> >
>> org.apache.logging.log4j.web.Log4jServletFilter.FILTERED=true
>> > Class: org.apache.catalina.core.ApplicationHttpRequest
>> > DispatcherType: FORWARD [javax.servlet.DispatcherType]
>> > HttpServletMapping: Class:
>> > org.apache.catalina.core.ApplicationMapping$MappingImpl
>> > MappingMatch: PATH MatchValue: setup/step_0.html Pattern:
>> > /WEB-INF/* ServletName: default
>> >
>> > Below is from the actual filter assigned to TC's default servlet
>> > intended to restrict access:
>> >
>> > ContextPath: /erm-0.0.1-SNAPSHOT DispatcherType: FORWARD PathInfo:
>> > /setup/step_0.html PathTranslated:
>> > D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\setup\step_0.html
>> >
>> >
>> Method: GET
>> > RequestURI: /erm-0.0.1-SNAPSHOT/WEB-INF/setup/step_0.html
>> > RequestURL:
>> > http://localhost:8080/erm-0.0.1-SNAPSHOT/WEB-INF/setup/step_0.html
>> > ServletPath: /WEB-INF ServletContext.ServletContextName: erm
>> > response: org.apache.catalina.connector.ResponseFacade
>> >
>> > I think everything seems correct except the PathTranslated.  It
>> > should be:
>> >
>> > D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\WEB-INF\setup\step_
>> 0.html
>> >
>> >  where the file is.  I'm unable to find out why it's wrong after a
>> > couple hours of searching since the the browser shows an empty
>> > page...  The string "/WEB-INF/setup/step_0.html" was passed to
>> > request.getRequestDispatcher(). According to the doc [1], " If the
>> > path begins with a "/" it is interpreted as relative to the current
>> > context root." everything is as it should be right, other than
>> > PathTranslated?  Or did I misunderstood the usage of
>> > getRequestDispatcher().forward()?  Currently, I have 4 filters in
>> > place and all are in passive monitoring mode.  None of them have
>> > the code logic to perform their intended functions.  3 filters
>> > mapped to URL /* and one assigned to TC's default servlet.  I'll
>> > work out their filtering order before the intended functions are
>> > implemented.
>>
>> Filters are applied in a predictable order. I highly recommend reading
>> the servlet specification to see how these things are defined to work.
>> It's quite readable.
>>
>> Why not allow Tomcat to serve everything in the web application (other
>> than /WEB-INF/* and /META-INF/*) as usual? What is it that you need to
>> put into there that you can't hide in some other way?
>>
>> It sounds like you are unnecessarily complicating your life.
>>
>> - -chris
>>
>
> I was using "/WEB-INF/*" as a test of the s

Re: Tomcat embedded

2019-06-20 Thread Tommy Pham
Hi Mark,

Thanks for the feedback.

On Mon, Jun 17, 2019 at 4:19 AM Mark Thomas  wrote:

> On 17/06/2019 01:04, Tommy Pham wrote:
> > Hello everyone,
> >
> > 1) Is there an official documentation for embedding TC process?  My
> search
> > shows various how-to on other sites.
> >a)  If not, I guess I could request to be added to the wiki to
> > contribute one.  Since I don't quite know all the details of TC, is
> there a
> > review process to ensure clarity and complete coverage of embedding
> process?
>
> The Javadoc is probably the best place to start:
> http://tomcat.apache.org/tomcat-9.0-doc/api/index.html
>
>
I have started browsing through the API and have concluded shortly
thereafter that, to me, the best way to implement it is similar to my
current use of ServletContainerInitializer.  Just need another class with
some adjustments and the app could run with Tomcat embedded.  I was hoping
to read something more akin to the official guide:

http://tomcat.apache.org/tomcat-9.0-doc/index.html


> There is a lot more information that could be presented there. Patches
> welcome.
>
> A Tomcat committer will review any patch before applying it.
>
> > 2) (probably better to ask the dev list?) I noticed there are some
> > differences in the official binary distribution vs development
> environment:
> >a)  Official has annotations-api.jar while development has according
> to
> > gradle:
> >
> > default - Configuration for default artifacts.
> > +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.+ -> 9.0.21
> > |\--- org.apache.tomcat:tomcat-annotations-api:9.0.21
> >
> > while the jar file names are different, the classes' name and the jar's
> > manifest within appear to the same.  I think this is trivial.
>
> Whenever you wonder why a line of code is they way it is, running git
> blame on the file is usually informative.In this case it will lead you to:
>
> https://github.com/apache/tomcat/commit/1386eaac4d07b6bbae69b3981fe1f873a56b7cae
>
>
> >b)  ecj version differences:  the official binary uses ecj-4.10.jar
> > while the development, per gradle, uses ecj-3.16:
>
> It is the same version. The difference is due to where the JARs are
> obtained from. The Tomcat build script gets it from The Eclipse IDE 4.10
> downloads - hence the version used. The pom.xml go directly to Maven
> Central which uses the internal version number 3.16. If you look in the
> manifests you'll see the internal version info is the same.
>
> Mark
>
>
Thank you for the clarification regarding the version differences.

Thanks again,
Tommy


Re: TC 9.0.21: ContextListener + Servlet app

2019-06-20 Thread Tommy Pham
Hi Chris,

On Mon, Jun 17, 2019 at 2:11 PM Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Tommy,
> > Tommy,
> >
> > On 6/15/19 21:51, Tommy Pham wrote:
> >>>> Hi Mark,
> >>>>
> >>>> After some research and thought about internal application
> >>>> flow, I think the 'cleanest' is have TC's default servlet
> >>>> handle the *.html requests and use the assigned filter to
> >>>> restrict the access as desired.  Is there a better approach?
> >>>> On that plan, I have this mapping for TC's default servlet
> >>>> and init:
> >>>>
> >>>> Filter AppFilterAccessLog's servlet mapping: Servlet name:
> >>>> default , registered class:
> >>>> org.apache.catalina.servlets.DefaultServlet. Servlet
> >>>> default's mapping: /img/* /css/* /WEB-INF/*
> >
> > Uh... you sure you want that? What is stopping a client from
> > requesting /WEB-INF/web.xml?
> >
> >>>> /js/* Servlet default's init parameters: listings: false
> >>>> debug: 0
> >>>>
> >>>> If I use *.html instead of /WEB-INF/*, it goes into infinite
> >>>> loop redirecting / forwarding until exception is thrown (I
> >>>> think that root cause is servlets' startup ordering).  Below
> >>>> are what my access log filter see for HttpServletRequest:
> >>>>
> >>>> Attributes:
> >>>> javax.servlet.forward.request_uri=/erm-0.0.1-SNAPSHOT/
> >>>> javax.servlet.forward.context_path=/erm-0.0.1-SNAPSHOT
> >>>> javax.servlet.forward.servlet_path=
> >>>> javax.servlet.forward.path_info=/
> >>>>
> >>>> javax.servlet.forward.mapping=org.apache.catalina.core.ApplicationM
> app
> >
> >>>>
> ing$MappingImpl@7fc1f887
> >>>>
> >>>>
> > org.apache.logging.log4j.web.Log4jServletFilter.FILTERED=true
> >>>> Class: org.apache.catalina.core.ApplicationHttpRequest
> >>>> DispatcherType: FORWARD [javax.servlet.DispatcherType]
> >>>> HttpServletMapping: Class:
> >>>> org.apache.catalina.core.ApplicationMapping$MappingImpl
> >>>> MappingMatch: PATH MatchValue: setup/step_0.html Pattern:
> >>>> /WEB-INF/* ServletName: default
> >>>>
> >>>> Below is from the actual filter assigned to TC's default
> >>>> servlet intended to restrict access:
> >>>>
> >>>> ContextPath: /erm-0.0.1-SNAPSHOT DispatcherType: FORWARD
> >>>> PathInfo: /setup/step_0.html PathTranslated:
> >>>> D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\setup\step_0.htm
> l
> >>>>
> >>>>
> >
> >>>>
> Method: GET
> >>>> RequestURI: /erm-0.0.1-SNAPSHOT/WEB-INF/setup/step_0.html
> >>>> RequestURL:
> >>>> http://localhost:8080/erm-0.0.1-SNAPSHOT/WEB-INF/setup/step_0.html
> >>>>
> >>>>
> ServletPath: /WEB-INF ServletContext.ServletContextName: erm
> >>>> response: org.apache.catalina.connector.ResponseFacade
> >>>>
> >>>> I think everything seems correct except the PathTranslated.
> >>>> It should be:
> >>>>
> >>>> D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\WEB-INF\setup\st
> ep_
> >
> >>>>
> 0.html
> >>>>
> >>>> where the file is.  I'm unable to find out why it's wrong
> >>>> after a couple hours of searching since the the browser shows
> >>>> an empty page...  The string "/WEB-INF/setup/step_0.html" was
> >>>> passed to request.getRequestDispatcher(). According to the
> >>>> doc [1], " If the path begins with a "/" it is interpreted as
> >>>> relative to the current context root." everything is as it
> >>>> should be right, other than PathTranslated?  Or did I
> >>>> misunderstood the usage of getRequestDispatcher().forward()?
> >>>> Currently, I have 4 filters in place and all are in passive
> >>>> monitoring mode.  None of them have the code logic to perform
> >>>> their intended functions.  3 filters mapped to URL /* and one
> >>>> assigned to TC's default servlet.  I'll work out their
> >>>> filtering order before the intended functions are
> >&

Re: TC 9.0.21: ContextListener + Servlet app

2019-06-20 Thread Tommy Pham
Hi Mark,

On Thu, Jun 20, 2019 at 3:58 AM Mark Thomas  wrote:

> On June 20, 2019 10:00:12 AM UTC, Tommy Pham  wrote:
>
> 
>
> >> In looking at the code for ApplicationHttpRequest [1] for the
> >> getPathTranlated()
> >>
> >> @Override
> >> public String getPathTranslated() {
> >> if (getPathInfo() == null || getServletContext() == null) {
> >> return null;
> >> }
> >> return getServletContext().getRealPath(getPathInfo());
> >> }
> >>
> >> and for the getRequestDispatcher()
> >>
> >> if (pathInfo == null) {
> >> requestPath = servletPath;
> >> } else {
> >> requestPath = servletPath + pathInfo;
> >>   }
> >>
> >> Perhaps the getPathTranslated() could be ?
> >>
> >> if ( getServletContext() != null) {
> >> if (getServletPath() != null) {
> >>if (getPathInfo() != null) {
> >>
> >>return getServletContext().getRealPath(getServletPath() +
> >> getPathInfo());
> >>}
> >>return getServletContext().getRealPath(getServletPath());
> >> }
> >> }
> >> return null;
> >>
> >> I think that would also fix the translated path I saw earlier which
> >> resulted in a blank page for the browser.
>
> Sorry, no. The Servlet spec defines the behaviour of those methods and
> Tomcat correctly implements the requirements of the Servlet spec.
>
> Mark
>
>
Based on my understanding, the getPathTranslated allows the TC's default
servlet to find the file located on the file system to fulfill the
request.  Since it's incorrect, how can I get the TC's default servlet to
work correctly?  Please clarify if I misunderstood getPathTranslated's
purpose or how TC's default servlet would find the file in question to
fulfill the request.

 Thank you,
Tommy


Re: TC 9.0.21: ContextListener + Servlet app

2019-06-20 Thread Tommy Pham
Hi Chris,

On Sat, Jun 15, 2019 at 10:44 PM Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Tommy,
>
> 
> Why not allow Tomcat to serve everything in the web application (other
> than /WEB-INF/* and /META-INF/*) as usual? What is it that you need to
> put into there that you can't hide in some other way?
>
> It sounds like you are unnecessarily complicating your life.
>
> - -chris
>

I just tried as you've suggested (only thing that I have is custom is a
passive Filter inspecting what's be passed around to various components
before reaching the TC's default servlet):

Class: org.apache.catalina.connector.RequestFacade
ServletContext Class: org.apache.catalina.core.ApplicationContextFacade
ContextPath: /erm-0.0.1-SNAPSHOT
DispatcherType: REQUEST
HttpServletMapping:
   Class: org.apache.catalina.core.ApplicationMapping$MappingImpl
   MappingMatch: DEFAULT
   MatchValue:
   Pattern: /
   ServletName: default
Method: GET
PathInfo: null
PathTranslated: null
Correction of PathTranslated:
D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\css\jquery-ui\base\index.html
RequestURI: /erm-0.0.1-SNAPSHOT/css/jquery-ui/base/index.html
RequestURL:
http://localhost:8080/erm-0.0.1-SNAPSHOT/css/jquery-ui/base/index.html
ServletPath: /css/jquery-ui/base/index.html
ServletContext.ServletContextName: erm
response: org.apache.catalina.connector.ResponseFacade

As you can see, even with that, I'm still getting a blank page on the
browser.  Also, _if_ I'm to serve static content only, I would better off
using Apache's httpd for more flexible configurations without writing one
line of code :)

Thanks,
Tommy


Re: TC 9.0.21: ContextListener + Servlet app

2019-06-20 Thread Tommy Pham


After some further research, it appears the issue I'm encountering is known
since 2007 by IBM at least:

https://www-01.ibm.com/support/docview.wss?uid=swg21259282

While reviewing the JSR-369 history, at jcp.org, it seems that this is
since servlet spec 2.3, perhaps even earlier.  Does anyone know if the
email spec-sub...@jcp.org is the correct email which I can submit a
proposal for updating the JSR-369?  I think the section 3.6 of the servlet
spect should be changed from:

"The getPathTranslated method computes the real path of the pathInfo of the
request."

to:

The getPathTranslated method computes the real path of the servletPath and
pathInfo of the request.  If the pathInfo is not valid, then compute the real
path of the servletPath.

Since the requestURI is comprise of /contextPath/servletPath/pathInfo.  I
think the above would be more accurate to translate the requested path to a
static file on the file system as I've seen by various cases, and possibly
IBM's too.

Servlet name: default , registered class:
org.apache.catalina.servlets.DefaultServlet.
Servlet default's mapping:
 /img/*
 /css/*
 /js/*
 *.html
Servlet default's init parameters:
 listings: false
 debug: 0
Class: org.apache.catalina.connector.RequestFacade
ServletContext Class: org.apache.catalina.core.ApplicationContextFacade
ContextPath: /erm-0.0.1-SNAPSHOT
DispatcherType: REQUEST
HttpServletMapping:
   Class: org.apache.catalina.core.ApplicationMapping$MappingImpl
   MappingMatch: PATH
   MatchValue: jquery-ui/base/index.html
   Pattern: /css/*
   ServletName: default
Method: GET
PathInfo: /jquery-ui/base/index.html
PathTranslated:
D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\jquery-ui\base\index.html
Correction of PathTranslated:
D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\css\jquery-ui\base\index.html
RequestURI: /erm-0.0.1-SNAPSHOT/css/jquery-ui/base/index.html
RequestURL:
http://localhost:8080/erm-0.0.1-SNAPSHOT/css/jquery-ui/base/index.html
ServletPath: /css
ServletContext.ServletContextName: erm
response: org.apache.catalina.connector.ResponseFacade

Thanks,
Tommy

>


Re: TC 9.0.21: ContextListener + Servlet app

2019-06-21 Thread Tommy Pham
Hi Mark,

On Thu, Jun 20, 2019 at 11:57 PM Mark Thomas  wrote:

> On 21/06/2019 03:21, Tommy Pham wrote:
> > 
> >
> > After some further research, it appears the issue I'm encountering is
> known
> > since 2007 by IBM at least:
> >
> > https://www-01.ibm.com/support/docview.wss?uid=swg21259282
> >
> > While reviewing the JSR-369 history, at jcp.org, it seems that this is
> > since servlet spec 2.3, perhaps even earlier.  Does anyone know if the
> > email spec-sub...@jcp.org is the correct email which I can submit a
> > proposal for updating the JSR-369?
>
> It isn't.
>
> The Java EE specs have moved to Eclipse and are in the process of
> re-branding to Jakarta EE. The process now is to raise an issue here:
>
> https://github.com/eclipse-ee4j/servlet-api
>
> However...
>
> >  I think the section 3.6 of the servlet
> > spect should be changed from:
> >
> > "The getPathTranslated method computes the real path of the pathInfo of
> the
> > request."
> >
> > to:
> >
> > The getPathTranslated method computes the real path of the servletPath
> and
> > pathInfo of the request.  If the pathInfo is not valid, then compute the
> real
> > path of the servletPath.
>
> Since I'm one of the folks who would respond to any such request, I can
> give you a heads up on the likely response.
>
> That is never going to happen. There are multiple reasons:
>
> 1. It would break backwards compatibility.
>
> 2. The purpose of getPathTranslated() is to map *just* the pathInfo to
> the file system. There are use cases that need this functionality.
>
> 3. You can use ServletContext.getRealPath(String path)
>
> > Since the requestURI is comprise of /contextPath/servletPath/pathInfo.  I
> > think the above would be more accurate to translate the requested path
> to a
> > static file on the file system as I've seen by various cases, and
> possibly
> > IBM's too.
>
> What is more likely to be accepted (but no guarantees) is a new method
> on ServletRequest getRealPath() (note the lack of parameter) that calls
> ServletContext#getRealPath() with servletPath + pathInfo (with
> appropriate null handling).
>
> Mark
>
>
Thank you for the clarification and the heads up. I greatly appreciate it.
I've been thinking about different methods of approach and I think this is
better than servletPath + pathInfo:

return getServletContext() == null ? null : getServletContext().
getRealPath(getRequestURI().substring(getContextPath().length()));

due to less conditional checks yielding better execution time and since I
can't see any condition that either requestURI or contextPath could be null:

hsr = (HttpServletRequest) request;

String pt = null;
final long startTime1 = System.currentTimeMillis();
pt = getPathTranslatedR1();
final long endTime1 = System.currentTimeMillis();
logger.debug(String.format("Correction of PathTranslated R1: %s
ms %s", (endTime1 - startTime1), pt));
pt = null;
final long startTime2 = System.currentTimeMillis();
pt = getPathTranslatedR2();
final long endTime2 = System.currentTimeMillis();
logger.debug(String.format("Correction of PathTranslated R2: %s
ms %s", (endTime2 - startTime2), pt));

 private String getPathTranslatedR1() {
if (hsr.getServletContext() != null) {
if (hsr.getServletPath() != null) {
if (hsr.getPathInfo() != null) {

return
hsr.getServletContext().getRealPath(hsr.getServletPath()
+ hsr.getPathInfo());
}
return hsr.getServletContext().
getRealPath(hsr.getServletPath());
}
return null;
}
return null;
}

private String getPathTranslatedR2() {

return hsr.getServletContext() == null ? null : hsr.
getServletContext().
getRealPath(hsr.getRequestURI().substring(hsr.getContextPath().length()));
}

Correction of PathTranslated R1: 1 ms
D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\css\jquery-ui\base\index.html
Correction of PathTranslated R2: 0 ms
D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\css\jquery-ui\base\index.html


As for the new method of getRealPath(), how does the web container knows
which is the correct one?  Does it then check if the file actually exists
for both getRealPath() and getPathTranslated() and compare?  Going forward
to have progress of my project, I'll have write to my own servlet to handle
static content instead of forwarding to TC's default servlet.  On the
bright side, I think I can have stricter enforcement ie:  "/css/*.css"

Thanks,
Tommy


Re: TC 9.0.21: ContextListener + Servlet app

2019-06-15 Thread Tommy Pham
Hi Mark,

After some research and thought about internal application flow, I think
the 'cleanest' is have TC's default servlet handle the *.html requests and
use the assigned filter to restrict the access as desired.  Is there a
better approach?  On that plan, I have this mapping for TC's default
servlet and init:

Filter AppFilterAccessLog's servlet mapping:
Servlet name: default , registered class:
org.apache.catalina.servlets.DefaultServlet.
Servlet default's mapping:
 /img/*
 /css/*
 /WEB-INF/*
 /js/*
Servlet default's init parameters:
 listings: false
 debug: 0

If I use *.html instead of /WEB-INF/*, it goes into infinite loop
redirecting / forwarding until exception is thrown (I think that root cause
is servlets' startup ordering).  Below are what my access log filter see
for HttpServletRequest:

Attributes:
javax.servlet.forward.request_uri=/erm-0.0.1-SNAPSHOT/
javax.servlet.forward.context_path=/erm-0.0.1-SNAPSHOT
javax.servlet.forward.servlet_path=
javax.servlet.forward.path_info=/

javax.servlet.forward.mapping=org.apache.catalina.core.ApplicationMapping$MappingImpl@7fc1f887
org.apache.logging.log4j.web.Log4jServletFilter.FILTERED=true
Class: org.apache.catalina.core.ApplicationHttpRequest
DispatcherType: FORWARD [javax.servlet.DispatcherType]
HttpServletMapping:
Class: org.apache.catalina.core.ApplicationMapping$MappingImpl
MappingMatch: PATH
MatchValue: setup/step_0.html
Pattern: /WEB-INF/*
ServletName: default

Below is from the actual filter assigned to TC's default servlet intended
to restrict access:

ContextPath: /erm-0.0.1-SNAPSHOT
DispatcherType: FORWARD
PathInfo: /setup/step_0.html
PathTranslated:
D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\setup\step_0.html
Method: GET
RequestURI: /erm-0.0.1-SNAPSHOT/WEB-INF/setup/step_0.html
RequestURL:
http://localhost:8080/erm-0.0.1-SNAPSHOT/WEB-INF/setup/step_0.html
ServletPath: /WEB-INF
ServletContext.ServletContextName: erm
response: org.apache.catalina.connector.ResponseFacade

I think everything seems correct except the PathTranslated.  It should be:

D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\WEB-INF\setup\step_0.html

where the file is.  I'm unable to find out why it's wrong after a couple
hours of searching since the the browser shows an empty page...  The string
"/WEB-INF/setup/step_0.html" was passed to request.getRequestDispatcher().
According to the doc [1], " If the path begins with a "/" it is interpreted
as relative to the current context root." everything is as it should be
right, other than PathTranslated?  Or did I misunderstood the usage of
getRequestDispatcher().forward()?  Currently, I have 4 filters in place and
all are in passive monitoring mode.  None of them have the code logic to
perform their intended functions.  3 filters mapped to URL /* and one
assigned to TC's default servlet.  I'll work out their filtering order
before the intended functions are implemented.

Thanks,
Tommy

[1]
http://tomcat.apache.org/tomcat-9.0-doc/servletapi/javax/servlet/ServletRequest.html#getRequestDispatcher-java.lang.String-


Re: TC 9.0.21: ContextListener + Servlet app

2019-06-16 Thread Tommy Pham
Hi Chris,

Thank you for the feedback.

On Sat, Jun 15, 2019 at 10:44 PM Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Tommy,
>
> On 6/15/19 21:51, Tommy Pham wrote:
> > Hi Mark,
> >
> > After some research and thought about internal application flow, I
> > think the 'cleanest' is have TC's default servlet handle the *.html
> > requests and use the assigned filter to restrict the access as
> > desired.  Is there a better approach?  On that plan, I have this
> > mapping for TC's default servlet and init:
> >
> > Filter AppFilterAccessLog's servlet mapping: Servlet name: default
> > , registered class: org.apache.catalina.servlets.DefaultServlet.
> > Servlet default's mapping: /img/* /css/* /WEB-INF/*
>
> Uh... you sure you want that? What is stopping a client from requesting
> /WEB-INF/web.xml?
>
> > /js/* Servlet default's init parameters: listings: false debug: 0
> >
> > If I use *.html instead of /WEB-INF/*, it goes into infinite loop
> > redirecting / forwarding until exception is thrown (I think that
> > root cause is servlets' startup ordering).  Below are what my
> > access log filter see for HttpServletRequest:
> >
> > Attributes: javax.servlet.forward.request_uri=/erm-0.0.1-SNAPSHOT/
> > javax.servlet.forward.context_path=/erm-0.0.1-SNAPSHOT
> > javax.servlet.forward.servlet_path=
> > javax.servlet.forward.path_info=/
> >
> > javax.servlet.forward.mapping=org.apache.catalina.core.ApplicationMapp
> ing$MappingImpl@7fc1f887
> >
> >
> org.apache.logging.log4j.web.Log4jServletFilter.FILTERED=true
> > Class: org.apache.catalina.core.ApplicationHttpRequest
> > DispatcherType: FORWARD [javax.servlet.DispatcherType]
> > HttpServletMapping: Class:
> > org.apache.catalina.core.ApplicationMapping$MappingImpl
> > MappingMatch: PATH MatchValue: setup/step_0.html Pattern:
> > /WEB-INF/* ServletName: default
> >
> > Below is from the actual filter assigned to TC's default servlet
> > intended to restrict access:
> >
> > ContextPath: /erm-0.0.1-SNAPSHOT DispatcherType: FORWARD PathInfo:
> > /setup/step_0.html PathTranslated:
> > D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\setup\step_0.html
> >
> >
> Method: GET
> > RequestURI: /erm-0.0.1-SNAPSHOT/WEB-INF/setup/step_0.html
> > RequestURL:
> > http://localhost:8080/erm-0.0.1-SNAPSHOT/WEB-INF/setup/step_0.html
> > ServletPath: /WEB-INF ServletContext.ServletContextName: erm
> > response: org.apache.catalina.connector.ResponseFacade
> >
> > I think everything seems correct except the PathTranslated.  It
> > should be:
> >
> > D:\apache-tomcat-9.0.21\webapps\erm-0.0.1-SNAPSHOT\WEB-INF\setup\step_
> 0.html
> >
> >  where the file is.  I'm unable to find out why it's wrong after a
> > couple hours of searching since the the browser shows an empty
> > page...  The string "/WEB-INF/setup/step_0.html" was passed to
> > request.getRequestDispatcher(). According to the doc [1], " If the
> > path begins with a "/" it is interpreted as relative to the current
> > context root." everything is as it should be right, other than
> > PathTranslated?  Or did I misunderstood the usage of
> > getRequestDispatcher().forward()?  Currently, I have 4 filters in
> > place and all are in passive monitoring mode.  None of them have
> > the code logic to perform their intended functions.  3 filters
> > mapped to URL /* and one assigned to TC's default servlet.  I'll
> > work out their filtering order before the intended functions are
> > implemented.
>
> Filters are applied in a predictable order. I highly recommend reading
> the servlet specification to see how these things are defined to work.
> It's quite readable.
>
> Why not allow Tomcat to serve everything in the web application (other
> than /WEB-INF/* and /META-INF/*) as usual? What is it that you need to
> put into there that you can't hide in some other way?
>
> It sounds like you are unnecessarily complicating your life.
>
> - -chris
>

I was using "/WEB-INF/*" as a test of the scaffolding for my application
since previously "*.html" ended up infinite loop which, eventually, it
threw an exception.  Now that I've got "*.html" working, I'm still getting
a blank page.  The HTML files are only served as UI for the initial setup
of the application.  There won't be any static files other than JS, CSS,
and images when the application is fully configured by administrator.  Here
are the servlets configuration:

Servlet name: default , re

Re: Tomcat embedded

2020-04-06 Thread Tommy Pham
On Mon, Apr 6, 2020 at 7:24 AM Mark Thomas  wrote:

>
> Check if JasperInitializer has been called. Depending on how you
> configure things, you'll need to do that explicitly.
>
> Mark
>
>
Hi Mark,

Your one suggestion helped me resolve this issue and another (WebSocket) in
less than 10 minutes that I've spent over 8 hours going through 5-6 classes
in addition researching online trying to identify the root cause.  Thank
you very much!

Regards,
Tommy


Re: Tomcat embedded

2020-04-05 Thread Tommy Pham
Hi Mark,

I've finally started my embedded Tomcat project.  I'm running into NPE for
the JSP servlet.  From the log:

https://pastebin.com/thiADVYE

I think I have everything setup correctly because accessing
http://localhost/css/sample.css works.  I've even added the 5 listeners in
the server.xml configuration while troubleshooting.  My JSP is really basic:

https://pastebin.com/X7R8weKv

When I inspecting the code where the NPE is thrown:

// Get the cached EL expression factory for this context
expressionFactory =
JspFactory.getDefaultFactory().getJspApplicationContext(
compiler.getCompilationContext().getServletContext()).
getExpressionFactory();

I couldn't figure out which part is the NPE.  I have the following jars:

*) all 4 tomcat-embed-*
*) tomcat-annotations-api
*) ecj-3.21
*) jstl 1.2 ( to troubleshoot this NPE )



On Thu, Jun 20, 2019 at 2:14 AM Tommy Pham  wrote:

> Hi Mark,
>
> Thanks for the feedback.
>
> On Mon, Jun 17, 2019 at 4:19 AM Mark Thomas  wrote:
>
>> On 17/06/2019 01:04, Tommy Pham wrote:
>> > Hello everyone,
>> >
>> > 1) Is there an official documentation for embedding TC process?  My
>> search
>> > shows various how-to on other sites.
>> >a)  If not, I guess I could request to be added to the wiki to
>> > contribute one.  Since I don't quite know all the details of TC, is
>> there a
>> > review process to ensure clarity and complete coverage of embedding
>> process?
>>
>> The Javadoc is probably the best place to start:
>> http://tomcat.apache.org/tomcat-9.0-doc/api/index.html
>>
>>
> I have started browsing through the API and have concluded shortly
> thereafter that, to me, the best way to implement it is similar to my
> current use of ServletContainerInitializer.  Just need another class with
> some adjustments and the app could run with Tomcat embedded.  I was hoping
> to read something more akin to the official guide:
>
> http://tomcat.apache.org/tomcat-9.0-doc/index.html
>
>
>> There is a lot more information that could be presented there. Patches
>> welcome.
>>
>> A Tomcat committer will review any patch before applying it.
>>
>> > 2) (probably better to ask the dev list?) I noticed there are some
>> > differences in the official binary distribution vs development
>> environment:
>> >a)  Official has annotations-api.jar while development has according
>> to
>> > gradle:
>> >
>> > default - Configuration for default artifacts.
>> > +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.+ -> 9.0.21
>> > |\--- org.apache.tomcat:tomcat-annotations-api:9.0.21
>> >
>> > while the jar file names are different, the classes' name and the jar's
>> > manifest within appear to the same.  I think this is trivial.
>>
>> Whenever you wonder why a line of code is they way it is, running git
>> blame on the file is usually informative.In this case it will lead you to:
>>
>> https://github.com/apache/tomcat/commit/1386eaac4d07b6bbae69b3981fe1f873a56b7cae
>>
>>
>> >b)  ecj version differences:  the official binary uses ecj-4.10.jar
>> > while the development, per gradle, uses ecj-3.16:
>>
>> It is the same version. The difference is due to where the JARs are
>> obtained from. The Tomcat build script gets it from The Eclipse IDE 4.10
>> downloads - hence the version used. The pom.xml go directly to Maven
>> Central which uses the internal version number 3.16. If you look in the
>> manifests you'll see the internal version info is the same.
>>
>> Mark
>>
>>
> Thank you for the clarification regarding the version differences.
>
> Thanks again,
> Tommy
>


Re: Tomcat embedded

2020-04-05 Thread Tommy Pham
On Sun, Apr 5, 2020 at 3:47 PM Tommy Pham  wrote:

> Hi Mark,
>
> I've finally started my embedded Tomcat project.  I'm running into NPE for
> the JSP servlet.  From the log:
>
> https://pastebin.com/thiADVYE
>
> I think I have everything setup correctly because accessing
> http://localhost/css/sample.css works.  I've even added the 5 listeners
> in the server.xml configuration while troubleshooting.  My JSP is really
> basic:
>
> https://pastebin.com/X7R8weKv
>
> When I inspecting the code where the NPE is thrown:
>
> // Get the cached EL expression factory for this context
> expressionFactory =
>
> JspFactory.getDefaultFactory().getJspApplicationContext(
> compiler.getCompilationContext().getServletContext()).
> getExpressionFactory();
>
> I couldn't figure out which part is the NPE.  I have the following jars:
>
> *) all 4 tomcat-embed-*
> *) tomcat-annotations-api
> *) ecj-3.21
> *) jstl 1.2 ( to troubleshoot this NPE )
>
>
I forgot to mention that the directory path org/apache/jsp was created
within workDir  /mnt/d/java/projects/ewa/build/ewa/temp/ROOT

Thanks,
Tommy