Re: java servlets, jsp and python

2010-05-05 Thread Xie Xiaodong
Hello, Maybe you could google about Jython for some hint.



On Wed, May 5, 2010 at 6:50 PM, Silvio Tschapke <
silvio.tscha...@googlemail.com> wrote:

> Hi all,
>
> I am new to Web-Programming and maybe my question is trivial. I want to
> build a dynamic webpage and want to use a python script within a java
> servlet.
> Is this possible?
> I thought that it is only possible to run java code within a servlet.
> Maybe I havn't understood the architecture right. Could anybody explain me
> how the web-container would call / interact with python?
> I haven't found this topic in the documentation.
>
> Cheers!
>



-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Tomcat scalability setting - need help please

2010-04-09 Thread Xie Xiaodong
Hello,



Maybe you could just export those data into Excel files (any other format
will do), and provide a download link to those file. Those files could be
generated lazily, means generate the first time it is requested.

I'm just curious, how do people in your company deal with millions of rows
of data with their own eyes?



On Fri, Apr 9, 2010 at 12:39 PM, Cin Lung  wrote:

> Hi George,
>
> Trust me the people in my client's company would see that much of data. It
> is needed by the production.
> The next best way I can do is to send the resultset object directly to the
> JSP, but I would not go to that extent just yet. I am going to either build
> a new cache mechanism or use ehcache. The companies where I cater is data
> hungry company.
>
> Thanks
> Rendra
>
> -Original Message-
> From: George Sexton [mailto:geor...@mhsoftware.com]
> Sent: Friday, April 09, 2010 12:50 AM
> To: 'Tomcat Users List'
> Subject: RE: Tomcat scalability setting - need help please
>
> Clearly instantiating millions of objects is not a strategy for
> scalability.
>
> You're going to have to re-structure your code to reduce the memory
> footprint of each session.
>
> Why is your result set returning a million rows? No human would want to see
> that much data.
>
> You need to restructure your queries and navigation design so that it
> doesn't do this.
>
> George Sexton
> MH Software, Inc.
> 303 438-9585
> www.mhsoftware.com
>
>
> > -Original Message-
> > From: Cin Lung [mailto:cinl...@gmail.com]
> > Sent: Thursday, April 08, 2010 10:53 AM
> > To: 'Tomcat Users List'
> > Subject: RE: Tomcat scalability setting - need help please
> >
> > Hi George
> >
> > Your remark is almost correct. What I did is that I store the result
> > of the resultset (which can go up to million lines of rows) in a batch
> > of Java beans. Then I set the beans to the HTTP Request and pass them
> > to the receiving JSP.
> >
> > But I do remember to return the connection to the pool. I also try to
> > kill the statements, result sets, etc by setting them to null. But I
> > realize that java might wait for the memory to be cleared by the
> > garbage collector.
> >
> > This goes back to my second problem. If the user closes the browser,
> > the request object form the servlet would lost its way to return the
> > result. And this will hog the tomcat performance for a while.
> >
> > Any tips would greatly be appreciated.
> >
> > TIA
> > Rendra
> >
> > -Original Message-
> > From: George Sexton [mailto:geor...@mhsoftware.com]
> > Sent: Thursday, April 08, 2010 11:42 PM
> > To: 'Tomcat Users List'
> > Subject: RE: Tomcat scalability setting - need help please
> >
> >
> > > -Original Message-
> > > From: Pid [mailto:p...@pidster.com]
> > > Sent: Thursday, April 08, 2010 8:49 AM
> > > To: Tomcat Users List
> > > Subject: Re: Tomcat scalability setting - need help please
> > >
> > > When you run the query in your application how are you doing it, e.g.
> > > by
> > > calling a stored procedure, or by executing exactly the same SQL
> > > statement?
> > >
> >
> >
> > Most likely the application is storing result sets on the session.
> >
> >
> >
> > George Sexton
> > MH Software, Inc.
> > 303 438-9585
> > www.mhsoftware.com
> >
> >
> > -
> > 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
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Error in start tomcat 5.5

2010-04-06 Thread Xie Xiaodong
tion of init method failed;
> nested exception is javax.naming.NameNotFoundException: Name jdbc is not
> bound in this Context
>
> at java.security.AccessController.doPrivileged(Native Method)
>
> ... 21 more
>
> Caused by: org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'sessionFactory': Cannot resolve reference
> to bean 'dataSource' while setting bean property 'dataSource'; nested
> exception is org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'dataSource': Invocation of init method
> failed; nested exception is javax.naming.NameNotFoundException: Name
> jdbc is not bound in this Context
>
> at java.security.AccessController.doPrivileged(Native Method)
>
> ... 22 more
>
> Caused by: org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'dataSource': Invocation of init method
> failed; nested exception is javax.naming.NameNotFoundException: Name
> jdbc is not bound in this Context
>
> at java.security.AccessController.doPrivileged(Native Method)
>
> ... 23 more
>
> Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in
> this Context
>
> at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
>
> at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>
> at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>
> at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>
> at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>
> at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>
> at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
>
> at javax.naming.InitialContext.lookup(InitialContext.java:392)
>
> ... 24 more
>
> log4j:ERROR LogMananger.repositorySelector was null likely due to error
> in class reloading, using NOPLoggerRepository.
>
> 06/04/2010 5:46:17 AM org.apache.coyote.http11.Http11BaseProtocol start
>
> INFO: Starting Coyote HTTP/1.1 on http-8080
>
> 06/04/2010 5:46:17 AM org.apache.jk.common.ChannelSocket init
>
> INFO: JK: ajp13 listening on /0.0.0.0:8009
>
> 06/04/2010 5:46:17 AM org.apache.jk.server.JkMain start
>
> INFO: Jk running ID=0 time=0/15  config=null
>
> 06/04/2010 5:46:17 AM org.apache.catalina.storeconfig.StoreLoader load
>
> INFO: Find registry server-registry.xml at classpath resource
>
> 06/04/2010 5:46:17 AM org.apache.catalina.startup.Catalina start
>
> INFO: Server startup in 7678 ms
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Access Log /Filter/?

2010-03-03 Thread Xie Xiaodong
Hello, Christopher,


For log.debug() part, seems I misunderstood your meaning. Sorry about that,
you are right. But I do not think it matters too much. :)



On Wed, Mar 3, 2010 at 5:54 PM, Xie Xiaodong  wrote:

> Hello,
>
>
> I think log.debug() method should first check current logging levels, or
> our code will have those if() {} template everywhere.
>
> I checked java.util.logging.Logger, and found this:
>
> public void log(Level level, String msg, Object param1) {
> if (level.intValue() < levelValue || levelValue == offValue) {
> return;
> }
> LogRecord lr = new LogRecord(level, msg);
>  Object params[] = { param1 };
> lr.setParameters(params);
> doLog(lr);
> }
>
>
> Java 6 hotspot can determine that the StringBuffer synchronization isn't
> actually used across threads in many cases, and thus it doesn't bother
> synchronizing. Thus, the performance of the two classes becomes identical.
>
> http://www.javalobby.org/java/forums/t88518.html
>
> But it is more secure to not depend on specific jvm version, so it is more
> appropriate to use StringBuilder when necessary.
>
>
> On Wed, Mar 3, 2010 at 5:19 PM, Christopher Schultz <
> ch...@christopherschultz.net> wrote:
>
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>>
>> Jason,
>>
>> On 3/2/2010 7:21 PM, Jason Brittain wrote:
>> >> Why does the request have to be an HTTP request in order to have the
>> >> access log run?
>> >
>> > That does seem to be a bug.
>>
>> Note that this is not actually a part of the AccessLogValve, it's just
>> part of Xie's implementation.
>>
>> > By default, the access logger logs the common
>> > log web server
>> > format, but of course it doesn't have to, so it should log non-HTTP
>> requests
>> > as well, but maybe
>> > only if a non-default pattern is configured?
>>
>> Fair enough: most of the information you'd want to log is from HTTP
>> requests (like the URI, for instance). The only things that are
>> available for non-HTTP requests are:
>>
>> - - current date/time
>> - - transaction time
>> - - number of bytes read and sent
>> - - local address
>> - - remote address
>> - - request attributes
>> - - server name
>>
>> Actually, that's quite a bit, but I've never seen an HTTP log that
>> doesn't log the URI :)
>>
>> >>> long t2 = System.currentTimeMillis();
>> >>> long time = t2 - t1;
>> >>
>> >> This isn't your choice, it's in the original code, but why not just do:
>> >>
>> >> long elapsed = System.currentTimeMillis();
>> >> ...
>> >> elapsed = System.currentTimeMillis() - elapsed;
>> >>
>> >> ??
>> >>
>> >> Fewer items on the stack, etc.
>> >>
>> >
>> > Except that then it is more difficult to debug.  Right?  It isn't as
>> easy to
>> > inspect the value of
>> > the current time if you perform the subtraction without first assigning
>> the
>> > current time to a
>> > variable.
>>
>> Fair enough, though debugging this timing code shouldn't really be
>> required.
>>
>> >>  > private Date getDate() {
>> >>> // Only create a new Date once per second, max.
>> >>> long systime = System.currentTimeMillis();
>> >>> AccessDateStruct struct = currentDateStruct.get();
>> >>> if ((systime - struct.currentDate.getTime()) > 1000) {
>> >>> struct.currentDate.setTime(systime);
>> >>> struct.currentDateString = null;
>> >>> }
>> >>> return struct.currentDate;
>> >>> }
>> >>
>> >> I don't understand why this is ThreadLocal, instead of just
>> synchronized
>> >> across the object. Maybe it's slightly faster to avoid the
>> >> synchronization and just use ThreadLocals, but I'm not sure how many
>> >> requests per second a single Thread is going to process, so I'm not
>> >> convinced that caching this data is worth the complexity it requires in
>> >> this class. I'd love to hear from a Tomcat dev about this.
>> >>
>> >
>> > Tomcat can (hopefully) answer a larger number of requests per second
>> > every year on decently modern hardware.  Benchmark it both ways on
>> > a re

Re: Access Log /Filter/?

2010-03-03 Thread Xie Xiaodong
 Right. Presumably, the Content-Length is synonymous with the above, but
> it might not be. Also, Content-Length is not always set, so you'll get a
> lot of "-" written in the log even when response bodies actually has
> content. In this implementation, "%b" is equivalent to
> "%{Content-Length}o".
>
> Counting bytes isn't that big of a deal, either. I'll submit a patch at
> some point... maybe using a different pattern character.
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkuOjCAACgkQ9CaO5/Lv0PAAmgCgt9QVocFjXVNB3t4ib6fWOUIL
> ++YAoKdpBuT1uhobAIxasRsdw/PaK00e
> =zS1q
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Access Log /Filter/?

2010-03-02 Thread Xie Xiaodong
Thank the comments. I should have rechecked this file before I sent it here.
:)

First, for the init() part: in the super class FilterBase, we have a init()
method which will do the initialization work you mentioned.

Second, you are absolutely right about the log.info(). I first wrote
like this for testing and forgot to get it back to debug level.

In modern jvm, it does not matter much between StringBuffer and
StringBuilder, jvm will change StringBuffer used in single
thread scenario into StringBuilder automaticlly. You could google this
information. There are some benchmark test about it.

I'll check the remaining part tomorrow morning. It is rather late now.

Wish you have a nice day.

Thanks for the comments.


On Tue, Mar 2, 2010 at 11:51 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Xie,
>
> On 3/2/2010 3:58 PM, Xie Xiaodong wrote:
> > public class AccessLogFilter
> > extends FilterBase {
>
> For the most part, you've just replaced the invoke() method with a
> doFilter() method and introduced init(), which calls start(). Then, you
> removed all the Lifecycle stuff.
>
> How will Filters be configured in TC7? If they will use the same
>
> 
>  
>
> ...style of configuration, then you'll need to have your init() method
> fetch all the init-param values and set those values on the
> AccessLogFilter before calling start().
>
> I might just re-name start() to init() and make whatever changes are
> necessary.
>
> > private static Log log = LogFactory.getLog(AccessLogFilter.class);
>
> Oh, the irony.
>
> > public void doFilter(ServletRequest request, ServletResponse response,
> > FilterChain chain) throws IOException, ServletException {
> >
> > log.info("In AccessLogFilter doFilter. ");
>
> Obviously, you can't have this log message at the INFO level. I'll
> assume that all logging currently in the code is for development
> purposes and will be removed for a final version.
>
> >  if (!isHttpServlet(request, response)) {
> > chain.doFilter(request, response);
> > return;
> > }
>
> Why does the request have to be an HTTP request in order to have the
> access log run? I would flip the logic around to only do the logging if
> the request is an HTTP request, rather than having this mid-method return.
>
> >  HttpServletRequest httpRequest = ((HttpServletRequest) request);
> >
> > HttpServletResponse httpResponse = ((HttpServletResponse) response);
> >
> > if (started && getEnabled()) {
> > // Pass this request on to the next filter in the filterChain
> > long t1 = System.currentTimeMillis();
> >
> > chain.doFilter(request, response);
> >
> > long t2 = System.currentTimeMillis();
> > long time = t2 - t1;
>
> This isn't your choice, it's in the original code, but why not just do:
>
> long elapsed = System.currentTimeMillis();
> ...
> elapsed = System.currentTimeMillis() - elapsed;
>
> ??
>
> Fewer items on the stack, etc.
>
> > Date date = getDate();
> > StringBuffer result = new StringBuffer();
>
> The original default size for the StringBuffer was 128 characters.
> Presumably, this was done to avoid the cost of re-sizing the
> StringBuffer whenever it grew too large. The default initial capacity of
> a StringBuffer is 16 characters, which is almost certainly too small for
> a reasonable access log entry. You should put the larger size back in.
>
> While you're at it, use StringBuilder instead to avoid the overhead of
> synchronization for an object in a single-threaded environment.
>
> > public void log(String message) {
>
> Maybe re-write this method to avoid having to convert from
> StringBuffer/StringBuilder to String: why do the work if you don't have to?
>
> > private static String lookup(String month) {
> > int index;
> > try {
> > index = Integer.parseInt(month) - 1;
>
> Why not have a dummy "month" at index 0 and /not/ subtract? Come on...
> we're smarter than the Sun engineers, right? 0 = January? Stupid...
>
> > private Date getDate() {
> > // Only create a new Date once per second, max.
> > long systime = System.currentTimeMillis();
> > AccessDateStruct struct = currentDateStruct.get();
> > if ((systime - struct.currentDate.getTime()) > 1000) {
> > struct.currentDate.setTime(systime);
> > struct.currentDateString = null;
> > }
> > return struct.currentDate;
> > 

Re: Access Log /Filter/?

2010-03-02 Thread Xie Xiaodong
  name.append(pattern.charAt(j));
}
if (j + 1 < pattern.length()) {
/* the +1 was to account for } which we increment
now */
j++;
list.add(createAccessLogElement(name.toString(),
pattern.charAt(j)));
i = j; /* Since we walked more than one character */
} else {
// D'oh - end of string - pretend we never did this
// and do processing the "old way"
list.add(createAccessLogElement(ch));
}
} else {
list.add(createAccessLogElement(ch));
}
replace = false;
} else if (ch == '%') {
replace = true;
list.add(new StringElement(buf.toString()));
buf = new StringBuffer();
} else {
buf.append(ch);
}
}
if (buf.length() > 0) {
list.add(new StringElement(buf.toString()));
}
return list.toArray(new AccessLogElement[0]);
}

/**
 * create an AccessLogElement implementation which needs header string
 */
private AccessLogElement createAccessLogElement(String header, char
pattern) {
switch (pattern) {
case 'i':
return new HeaderElement(header);
case 'c':
return new CookieElement(header);
case 'o':
return new ResponseHeaderElement(header);
case 'r':
return new RequestAttributeElement(header);
case 's':
return new SessionAttributeElement(header);
default:
return new StringElement("???");
}
}

/**
 * create an AccessLogElement implementation
 */
private AccessLogElement createAccessLogElement(char pattern) {
switch (pattern) {
case 'a':
return new RemoteAddrElement();
case 'A':
return new LocalAddrElement();
case 'b':
return new ByteSentElement(true);
case 'B':
return new ByteSentElement(false);
case 'D':
return new ElapsedTimeElement(true);
case 'h':
        return new HostElement();
case 'H':
return new ProtocolElement();
case 'l':
return new LogicalUserNameElement();
case 'm':
return new MethodElement();
case 'p':
return new LocalPortElement();
case 'q':
return new QueryElement();
case 'r':
return new RequestElement();
case 's':
return new HttpStatusCodeElement();
case 'S':
return new SessionIdElement();
case 't':
return new DateAndTimeElement();
case 'T':
return new ElapsedTimeElement(false);
case 'u':
return new UserElement();
case 'U':
return new RequestURIElement();
case 'v':
return new LocalServerNameElement();
case 'I':
return new ThreadNameElement();
default:
return new StringElement("???" + pattern + "???");
}
}
}


On Tue, Mar 2, 2010 at 9:45 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Xie (or is it Xiaodong?),
>
> On 3/2/2010 2:57 PM, Xie Xiaodong wrote:
> > I submitted some code but not including the AccessLogFilter since I had
> > something question about the implementation of it. Here I give you the
> > version I wrote last summer. Hope you could check it and submit a patch.
>
> Your attachment must have been stripped from the list. Please consider
> re-posting inline.
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkuNeOkACgkQ9CaO5/Lv0PBqXQCfUCrW3JCxOfU7tL1mnuJjwumC
> oRQAnRKH+Xizgh5iimVvQjq8rGZ1wTte
> =tCKO
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Access Log /Filter/?

2010-03-02 Thread Xie Xiaodong
Hello, Christopher,


I submitted some code but not including the AccessLogFilter since I had
something question about the implementation of it. Here I give you the
version I wrote last summer. Hope you could check it and submit a patch.


On Tue, Mar 2, 2010 at 6:41 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Xie,
>
> On 2/26/2010 4:33 PM, Xie Xiaodong wrote:
> > No, there is no AccessLogFilter in Tomcat 7 for now. I've got my
> > version of AccessLogFilter during Google Summer Code 2009, but has
> > not yet submit it for some reason.
>
> Uh, why not submit it and get paid?
>
> > Please attach your version so we could discuss it and make an
> > AccessLogFilter in Tomcat 7.
>
> I don't have a version, yet. I was checking to see if someone had done
> it already. But if I give you my code so Google can pay you, I'd like
> some of that money :)
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkuNTeUACgkQ9CaO5/Lv0PCOOwCeM78myOdUfyyHxTTrbQloeb3W
> Ja8AnA4gDir14UAIIoG9hoc8YcKMEeJ6
> =nst1
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong

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

Re: Access Log /Filter/?

2010-02-26 Thread Xie Xiaodong
Hello, Christopher,


No, there is no AccessLogFilter in Tomcat 7 for now. I've got my version of
AccessLogFilter during Google Summer Code 2009, but has not yet submit it
for some reason. Please attach your version so we could discuss it and make
an AccessLogFilter in Tomcat 7.



On Fri, Feb 26, 2010 at 10:07 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> All,
>
> I just started to write a filter that did request timing logging, and I
> looked at AccessLogValve for inspiration for how to parse a log pattern
> and then spit it out for every request.
>
> I realized that AccessLogValve can actually do everything I want it to
> do, already: log request time plus some request attributes.
>
> However, I may have occasion to want to /skip/ some of the transaction
> timing: that is, say, insert it between existing filters. That's not
> possible (that I know of) for Valves, because they are always before
> Filters in the pipeline.
>
> I believe Tomcat 7 is discarding Valves in favor of using the Filter
> interface. Is there already in existence an AccessLogFilter?
>
> I checked svn and I can see that AccessLogValve is in the 'valves'
> package, and that there /is/ a 'filters' package but it only has a
> subset of 'valves' that we've all grown to love.
>
> Is this just a class that hasn't been updated for TC7, yet?
>
> If so, I'd be happy to do the conversion and submit my code for inclusion.
>
> Thanks,
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkuIOB8ACgkQ9CaO5/Lv0PCS4ACfQxM/Oe2/4frguG3iKUbY2VmX
> FEgAn0N7e0FbuvNV5aNt2kSt3SedGCdV
> =vqsC
> -END PGP SIGNATURE-
>
> ---------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Character encoding for POST x-www-form-urlencoding (a success story)

2010-02-12 Thread Xie Xiaodong
Very nice work, Thank you for the sharing.



On Fri, Feb 12, 2010 at 11:23 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> All,
>
> My company recently decided to alter our password complexity
> requirements for our webapp, and I got to implement the changes. What fun!
>
> We use a regular expression to enforce our password complexity, and it
> needed to be changed. Since we are starting to branch-out into
> populations that aren't necessarily using written English everywhere, I
> chose to change our naive [a-z]- and [A-Z]-type checking to a mroe
> enlightened \p{Ll} and \p{Lu}, respectively. (Readers' note: jakarta-oro
> does not support this notation, so you'll want to use Java's built-in
> regular expression support to do this).
>
> Anyhow, when making changes to things security-related, it pays to test
> /everything/, so I grabbed 4 other people from my group and had them
> each test 15 sample passwords against our 6 different forms that accept
> password-change entry. Everything went fine.
>
> Except when I then tried to login from our home page with the password
> "1πππ" (that's a '1' digit followed by 7 Greek Pi characters, in
> case your email reader can't render that), and I got a failure. I
> figured I must have fat-fingered something, so I tried again and all was
> well.
>
> My spidey-sense tingling, I logged-out and repeated the process: again,
> my first login attempt was unsuccessful, while the second was. Hmm. Upon
> closer inspection, our opening page is a static HTML file served by
> Apache httpd -- no Tomcat involvement. After a failed login, a page that
> looks exactly like the home page is sent to the user, but it's
> different: /and/ it's served by Tomcat.
>
> The difference was that the original request's response (for
> /index.html) had a Content-Type of "text/html", while the failed login
> had a response Content-Type of "text/html; charset=UTF-8".
>
> It's out old pal "what's the default encoding, again?" coming back to
> haunt me, and here I am telling people on this list that they just don't
> understand the history of the web and how to do things properly.
> Evidently, I wasn't doing them properly, either.
>
> All those complaints about the way that URL-encoded GET parameters can
> get messed up based upon Content-Type and encoding guesses, etc. and the
> solution is just to use POST is, well, only half the truth. Yes, POST
> gets you away from the browser's preference for what encoding to use
> before URL-encoding the bytes, but, with POST the Content-Type is
> application/x-www-form-urlencoded, which means there's no charset
> associated with it. :(
>
> So, what's to be done?
>
> Well, I immediately thought of two solutions:
>
> 
> and
> 
>
> Knowing that web browsers are notoriously inconsistent with one another
> regarding certain things, I was sure that I'd have a giant mess when it
> came to testing, and that I'd have to figure out how to trick each
> version of each browser into doing my bidding.
>
> First, I had to make sure that they all /failed/ in the same way (that
> is to say, that the login failed the way I expected it to fail), then I
> had to see what magical incantations would be necessary to actually get
> the login to succeed.
>
> I'm happy to report that, for /all/ of the following browsers, */both/*
> solutions worked!
>
> Mozilla Firefox 2.0
> Mozilla Firefox 3.0
> Mozilla Firefox 3.5
> Mozilla Firefox 3.6
> Opera 9.6
> Opera 10.10
> Apple Safari 3.2
> Apple Safari 4.0
> Google Chrome 4.0
> MSIE 6.0
> MSIE 7.0
> MSIE 8.0
>
> I'm inclined to use the  solution, because
> that does not involve lying to the browser about the encoding of the
> actual HTML document. Instead, I'd rather advertise that I will only
> accept UTF-8 encoding and leave it at that. Sadly, the client still
> doesn't tell me that the underlying encoding being used to urlencode the
> POST parameters is UTF-8, but at least they're doing what I want them to
> do, and they all agree on behavior!
>
> So, score 1 for standards, at least in this instance.
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkt11PoACgkQ9CaO5/Lv0PC+OACgtobt70NWFxYJzcRt5r0zXlaN
> tYEAn0ZYnB/oehIoZR0NUs7Q/4mOux7x
> =U0Wt
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Memory analysis after 'OutOfMemoryError PermGen space' error induced by redeployments

2009-06-23 Thread Xie Xiaodong
---
>>mindmatters GmbH & Co. KG
>> Neuer Kamp 30
>> 20357 Hamburg - St. Pauli
>>
>> Fon: +49 40 4840593 0
>> Fax: +49 40 4840593 9
>> Website: www.mindmatters.de
>>
>> Handelsregister: Amtsgericht Hamburg | HRA 97304 | UID DE225251880
>> Persönl. haftende Gesellschafterin: mindmatters Verwaltungsgesellschaft
>> mbH
>> Amtsgericht Hamburg | HRB 84595 | Geschäftsführer: Frank Schmitz
>>
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>
> Viele Grüße
> Timo Meinen
>
> --
> -------
> mindmatters GmbH & Co. KG
> Neuer Kamp 30
> 20357 Hamburg - St. Pauli
>
> Fon: +49 40 4840593 0
> Fax: +49 40 4840593 9
> Website: www.mindmatters.de
>
> Handelsregister: Amtsgericht Hamburg | HRA 97304 | UID DE225251880
> Persönl. haftende Gesellschafterin: mindmatters Verwaltungsgesellschaft mbH
> Amtsgericht Hamburg | HRB 84595 | Geschäftsführer: Frank Schmitz
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: xml validation on -- good idea or not?

2009-05-20 Thread Xie Xiaodong
I think it just validates the xml file using the DTDs or xml-schemas
specified in your xml file. If you could not connect to the url you
specified in the dtds or xml-schemas, the situation you encountered might
happen.



2009/5/20 Julian Dunn 

>
> Hi,
>
> Is it a good idea to run with xmlValidation="true" in server.xml?
>
> I had this on for a while, but then it mysteriously stopped working --
> the container could no longer validate DTDs, refused to load webapps,
> etc.
>
> What does xmlValidation="true" actually do?
>
> I am using Tomcat 5.5.23.
>
> - Julian
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Trouble parsing datetime strings

2009-05-11 Thread Xie Xiaodong
Hello,

"Date formats are not synchronized. It is recommended to create separate
format instances for each thread. If multiple threads access a format
concurrently, it must be synchronized externally."
This is from the reference of JDK API.


2009/5/11 David kerber 

> This is related to the performance issues discussed in the thread
> "Performance with many small requests".
>
> When I reworked my servlet to synchronize only on pieces that needed to be
> synchronized, rather than on the entire request processing routine, I am now
> throwing an exception when parsing a string into a java.util.Date variable.
>  It only happens occasionally, maybe once every few dozen to a hundred or so
> requests, and I can't figure out why it doesn't work all the time.
>
> Declared at the class level, I have:
>
>   private static final SimpleDateFormatsdfFullDateTime = new
> SimpleDateFormat( "-MM-dd HH:mm:ss" );
>
>
> Then in the request processing method, I have
>
>   dateTimeStr = dateStr + " " + timeStr;
>   try {
>   dataDate = sdfFullDateTime.parse( dateTimeStr );
>   } catch ( Exception e ) {
>   writeLog( "Unable to parse dataTime string: '", dateTimeStr + "': " +
> e );
>   }
>
>
> (the try/catch is there only for debugging this issue), and in the log I'm
> seeing:
>
> 2009-05-11 09:19:54: Unable to parse dateTime string: ':  '2009-05-11
> 09:19:37': java.lang.NumberFormatException: For input string: ""'
>
>
> Which I don't understand at all; dateDate (java.util.Date), dateStr
> (String), timeStr (String) and dateTimeStr (String) are all declared in the
> processing method, NOT at the class level.
>
> Maybe I should move the declaration of the SimpleDateFormat into the
> processing method?  Or synchronize the date parse?
>
>
> I'm kind of lost here; any help appreciated!!
>
> Dave
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Performance with many small requests

2009-05-07 Thread Xie Xiaodong
Hello,

  IMHO, it would be better to use java concurrency package now than to use
the old synchronize mechanism. The old mechanism is to low level and error
prone. I think you could have a thread pool and some handler pattern to
handle the request from your customer.



2009/5/8 Andre-John Mas 

>
> On 7-May-2009, at 19:05, David Kerber wrote:
>
>  Andre-John Mas wrote:
>>
>>>
>>> That would be my impression too. It is best to avoid making the
>>> synchronized scope so large, unless there is a very good reason.
>>>
>>> David, do you have any reason for this? Beyond the counter, what other
>>> stuff do you synchronise? Also, it has generally been recommended to me to
>>> avoid hitting the disk in every request, since you may result with an I/O
>>> bottle neck, so if you can write the logs in batches you will have better
>>> performance. If you know that you are only going to have very few users at a
>>> time (say, less than 10), it may not be worth the time optimising this, but
>>> if you know that you are going to get at least several hundred, then this is
>>> something to watch out for.
>>>
>>
>> Thanks for the comments, Andre-John and Peter.  When I wrote that app, I
>> didn't know as much as I do now, but I'm still not very knowledgeable
>> about synchronized operations.
>>
>> The synchronized section doesn't do a whole lot, so it doesn't take long
>> to process.  My question is, what kinds of operations need to be
>> synchronized?  All I do is decrypt the data from the POST, send a small
>> acknowledgement response back to the site, and write the line to the log
>> file.  Does that sound like something that would need to be
>> synchronized?  If not, pulling that out would be a really easy test to
>> see if it helps my performance issue.
>>
>>
> I am no expert in this myself, but I know enough to help me out in most day
> to day scenarios. What you should be reading up on is concurrency in Java. A
> few useful resources:
>
>  site: http://java.sun.com/docs/books/tutorial/essential/concurrency/
>  book:
> http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601
>
> I actually bought the book myself and find it a handy reference.
>
> What I can say is that any time two threads are likely to access the same
> object, which has the potential to be modified by one of them, then you will
> need to synchronize access to the object. If the object is only going to be
> read during the life of the "unit of work", then you will need not
> synchronize it. You shouldn't simply use the synchronize keyword as a
> magical "solve all" for threading issues and instead need to understand what
> the nature of the interactions are between the threads, if any. In certain
> cases it is actually better to duplicate the necessary resources, have each
> thread work on its copy and then synchronize the value at the end.
>
> In the case of your code, you should ask what are the shared objects that
> are going to modified by the threads. You should also look if it is even
> necessary for the objects to be shared. Also consider whether for the call
> cycle the objects you are going to modify are only available on the stack,
> as opposed to a class or instance member.
>
> To give you a real world analogy: consider a home that is being built and
> you have an electrician and a plumber:
>  - is it better to have one wait until the other is finished (serial
> execution)?
>  - is it possible for them to be working on different stuff and not be
> stepping on each other's feet? (parallel execution)
>  - if you need them to work at the same time, what is the cost of
> coordinating each other so that
>they do not interfere with the other? (synchronization issues)
> In many ways multi-threading is not much different, and you should be
> asking yourself the same type of questions.
>
> André-John
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: After deployment to tomcat: entity class not found

2009-05-07 Thread Xie Xiaodong
 not found: Regional
> at
>
> org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
> at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
> at
>
> org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
> at
> org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:123)
> at
>
> org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:434)
> at
>
> org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109)
> at
>
> org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
> at
> org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:226)
> at
>
> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
> at
>
> org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)
> at
>
> org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)
> at
>
> org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
> at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
> at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
> ... 41 more
> Caused by: java.lang.ClassNotFoundException: MyClass
>
>
> Has anyone encountered this problem lately ? Thanks for your comments.
>



-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Tomcat Configuration in Eclipse

2009-05-04 Thread Xie Xiaodong
Hello,
  Maybe you could just simply reboot your computer and try to start Tomcat
again.



2009/5/4 André Warnier 

> ados1...@gmail.com wrote:
>
>> I checked machine startup options and tomcat is not started as a service
>> in
>> my machine
>>
>
> Then something else is running and using port 8005.
> You can either try to stop that process, or else change the port 8005 in
> Tomcat's server.xml file, to something else (8006 ?).
>
>
>
>
>>
>> On Mon, May 4, 2009 at 12:12 PM, Sid Sidney  wrote:
>>
>>  I would check and make sure that Tomcat is not being started as a service
>>> in your machine.
>>>
>>> --- On Mon, 5/4/09, ados1...@gmail.com  wrote:
>>> From: ados1...@gmail.com 
>>> Subject: Re: Tomcat Configuration in Eclipse
>>> To: "Tomcat Users List" 
>>> Date: Monday, May 4, 2009, 1:54 PM
>>>
>>> Hello,
>>> With the help of Plugin Tomcat is being configured in Eclipse.
>>>
>>> But now when I am trying to run my jsp page on Tomcat server than it is
>>> not
>>> running and am getting following message :
>>>
>>> "Several ports (8005, 8080, 8009) required by Tomcat v4.1 Server at
>>> localhost are already in use. The server may already be running in
>>> another
>>> process, or a system process may be using the port. To start this server
>>> you
>>> will need to stop the other process or change the port number(s)."
>>>
>>> I have stopped server and restarted again but still am getting same
>>> message
>>> and so bit confused with what is happening.
>>>
>>> Thanks,
>>> Ados
>>>
>>>
>>> On Mon, May 4, 2009 at 11:12 AM, ados1...@gmail.com
>>> wrote:
>>>
>>>  Thank you Sir,
>>>> My issue has been resolved. I really appreciate efforts that group
>>>>
>>> member's
>>>
>>>> are putting in to guide Tomcat Community.
>>>>
>>>> Regards,
>>>> Ados
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, May 4, 2009 at 8:05 AM, Martin Gainty 
>>>>
>>> wrote:
>>>
>>>> Please download and install tomcat sysdeo for eclipse plugin from
>>>>> http://www.eclipsetotale.com/tomcatPlugin.html
>>>>> and follow all the configuration instructions from
>>>>> readme.html
>>>>>
>>>>> Martin
>>>>> __
>>>>> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung /
>>>>> Note de déni et de confidentialité
>>>>> This message is confidential. If you should not be the intended
>>>>>
>>>> receiver,
>>>
>>>> then we ask politely to report. Each unauthorized forwarding or
>>>>> manufacturing of a copy is inadmissible. This message serves only for
>>>>>
>>>> the
>>>
>>>> exchange of information and has no legal binding effect. Due to the
>>>>>
>>>> easy
>>>
>>>> manipulation of emails we cannot take responsibility over the the
>>>>>
>>>> contents.
>>>
>>>> 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.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>  From: ados1...@gmail.com
>>>>>> Date: Mon, 4 May 2009 07:17:17 -0600
>>>>>> Subject: Tomcat Configuration in Eclipse
>>>>>> To: users@tomcat.apache.org
>>>>>>
>>>>>> Hi,
>>>>>> I am trying to configure TOMCAT Webserver in Eclipse and am not
>>>>>>
>>>>> able to
>>>
>>>> do
>>>>>
>>>>>> that. Guidance on the matter would be highly appreciated.
>>>>>>
>>>>>> Also, how can I access local jsp page which is on the WebApps
>>>>>>
>>>>> folder in
>>>
>>>> Webserver from Browser ?
>>>>>>
>>>>>> Thanks,
>>>>>> Ados
>>>>>>
>>>>> _
>>>>> Hotmail® has ever-growing storage! Don’t worry about storage
>>>>>
>>>> limits.
>>>
>>>>
>>>>>
>>> http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage1_052009
>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: Application-specific jar files with Tomcat v6.0

2009-05-01 Thread Xie Xiaodong
Hi,
   Are there any conflict between your jar and those jars used by Tomcat?



2009/4/30 

> Hi,
>
> I am deploying an axis2 web service with Tomcat v6.0.
>
> The web service required a third-part jar file, say x.jar
> I can make the work service working with Axis2 standalone server by putting
> x.jar into [axis2_home]/lib.
>
> According to Tomcat documents and corresponding discussion, I put x.jar
> into [Tomcat 6.0_home]\webapps\axis2\WEB-INF\lib, as deploying with Tomcat
> 6.However, it does NOT work!
>
> Then, I tried to put x.jar onto [Tomcat 6.0_home]\lib, although I
> understand it is not a good idea.
> It still does NOT work!
>
> At end, I add x.jar to the java classpath using the Tomcat 6 configure GUI
> (the small icon).
> It works this time!
>
> So I wonder if it is a bug of Tomcat 6, or I did something wrong.
> I suppose that it be a very common issue and have been heavily discussed.
> Why it is still there?
>
> I would be very grateful if I can get an answer. In addition, other users
> may also have experienced the same issue.
>
>
> Thanks,
> --
> shiping.c...@csiro.au<mailto:shiping.c...@csiro.au>
>
>
>
>
>
>


-- 
Sincerely yours and Best Regards,
Xie Xiaodong


Re: help on tomcat 5.0 log (stdout) setup or redirection

2009-04-30 Thread Xie Xiaodong
Hello,

You can find log file in the directory: /logs,
and you could have your own log4j.xml file (if you use log4j do your logging
job) specifying the location you want your log find at.





2009/4/30 Xiaohao Jiang 

> Hi there,
>
> I am really new to tomcat basic configuration. I am using a tomcat 5.0,
> coming with a digital object repository. It uses the command line to start
> the server (tomcat and the application). Anyway, my problem is that I can
> only see the tomcat log on the console, but i don't have it in any file.
> However, sometimes the application throws a serial of exceptions and I
> cannot get those scrolled away in the console.
>
> What I want is to have the log information stored in a file. I tried
> something like startup.bat > C:\log.txt, but the tomcat window just pops up
> and output logs in console.
>
> anybody can help?
>
> Many thanks,
> Hao
>



-- 
Sincerely yours and Best Regards,
Xie Xiaodong