Re: RTFM
no, I'm not returning anything from the servlet. It's not returning anything! You must return after using sendRedirect, otherwise your servlet will continue running. That's probably the problem, as it redirects you to another page, but continues it's execution. Try returning. Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
servlet mappings
Yes there any way i can programatically find out the servlet mappings defined in web.xml? Best regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: xhtml and Internet Explorer
That's because IE ignores the Content-Type header and just looks at the first few bytes of the file to decide how to display it. What a POS. Anyway... (Christopher Schultz) IE works like this: in the first call to a web page, it checks the Content-Type and displays the web page accordingly. Next time you request the same page, it ignores the Content-Type. I know that this issue came up before on this list, but the solution suggested previously (adding a page directive with the content type) does not work. (Marius Scurtescu) So, do the following: 1. You have to make sure IE is foing to display the most recent page. You can do this by either adding a pragma/no-cache header, or go to (in IE): tools/internet options/temporary internet files/settings and, under check for newer versions of stored pages, select the every visit to the page option. When you are developing, this last thing should ALWAYS be done. Otherwise, you might be getting IE cached versions of the web page and asking yourself why the changes aren't working. 2. Force IE to read the Content-Type again. Simply shut down the browser, and request your xhtml page to see if it works. Hope that helps. Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Factory methods.
Factory is a design pattern. Design patterns are ways of designing objects that are typical and have been used before, and thus can be reused (note: reuse of the design, not the source code). Have you ever heard about the Model-View-Controller (MVC) design pattern, for instance? You'll find design patterns in lots of APIs, so knowing about them helps you understand things better. Probably, you have come across more design patterns without even knowing. If you want to know more about design patterns, just google for it. Or try http://www.bruceeckel.com/ and find a book about design patterns there; it starts with the basics. Regards, Carlos Pereira - Original Message - From: anunay ashish [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, October 28, 2003 11:35 AM Subject: Factory methods. Why are some methods called factory methods? e.g. prepareStatement() in java.sql.PreparedStatement - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JDBC Connection question
Which server do you use? Weblogic, Websphere, ... support connection pooling. (Caroline Jen) Oracle 9iAS Supports DataSources with pooling as well. (Wade Chandler) Thats not the issue. Whatever server i use, i'll have to deploy the application somewhere. My company does not have any servers, so we have to use an outside server. Won't the need to configure server.xml (or something similar) give me any troubles? Why isn't it possible to configure connection pooling through web.xml? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JDBC Connection question
You can only run one transaction per connection. Also, your DBMS may support a limited number of threads per connection. (Wade Chandler) Ok. So, using one connection for the whole application is out of question. My other alternatives are connection pooling and using one connection per user. The server is supposed to have between 300/1000 people online at a time. I'm sure my question is very basic, but i want to know: what does it mean to have 1000 concurrent connections to the database (lets forget the dbms connection limit, just performance)? Please use a connection pool. For Instruction: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html and http://www.mysql.com/articles/connection_pooling_with_connectorj.html (Caroline Jen) I read it all. Connection pooling looks like the solution for all my problems. But, i had to configure server.xml to put it working. What about when i have to deploy the application? And if the server is NOT Tomcat, will it support connection pooling? Best regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Request, response and session.
JSP is built on top of Servlets. JSP pages are actually transformed into servlets. So, if you're serious about starting to program in JSP, i would recommend that you learn the basics of servlets before jumping into JSP. http://java.sun.com/products/servlet/docs.html is the Java Servlet Documentation page and should have everything you need. Starting out with Servlet Essentials is a good bet; it covers the very basics and you will learn very fast. Including the equivalent to Request and Response, and sessions. Regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: File writing performance
The main problem with performance comes from your source code. You are reading 1 byte at a time then writing 1 byte at a time. Use a buffered input stream, and also use a buffered output stream (Wade Chandler) Really efficient values are FS blocksize (linux defaults to 4096b). (Francois JEANMOUGIN) (Have a look at the source of the DefaultServlet) (Ralph Einfeldt) Ok, I'll use a 4096b long buffer. The code i posted was just a test; it worked, now i'll go for performance tuning. My doubt was if it would be slower that the processing that the default servlet does. After watching it's source i guess it will even be quicker, because it doesn't need so many tests. There is another problem: Are you shure that flash is using a simple download and won't use things from http 1.1 like byte range requests (and won't do it in the next version). (Ralph Einfeldt) I don't understand what you are talking about. SWF files work just like java applets; they are downloaded, the flash player is started and runs the SWF file (much like the java plugin). I really don't know anything about byte range requests. According to this behaviour, do you think there might be any problem? I've searched the SWF file format specification, macromedia's developer center and Flash's help files. They don't have any reference to that either. I tried an example and it worked fine, with no problems at all. But, i want to make sure i don't need to worry about this... Best regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: File writing performance
I don't know how it is with SWF files. But other technologies like PDF work with byte range requests to start the display of the first page before the full dokument is there. (Ralph Einfeldt) Oops! Flash does show frames as they come in, before the whole swf file is downloaded... My remark was just a warning, that something like that can happen. (Ralph Einfeldt) Yes, and i don't know anything about that, so i must be careful. What is the consequence, if flash uses byte range requests and i simply write the file to the output stream? Best regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JDBC Connection question
Hi list, my application currently uses ONE connection object to communicate with the database. The connection is set with an initializer servlet (load_on_stratup=0), and all users use that connection to retrieve data. Is this the best approach, or should i create a connection per user? Why? Where can i know more? The security system works on top of the database, so that's not a problem. I'm more concerned with performance and concurrency. Regards and thanks, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
File writing performance
I want to make a servlet which catches all accesses to *.swf files (with a mapping) and only retrieves them if the permissions for the user allow it. That can be done simply with: code // check user permissions and redirect to error page if needed // else: response.setContentType(application/x-shockwave-flash); DataInputStream dis = new DataInputStream( getServletContext().getResourceAsStream(filename) ); OutputStream out = response.getOutputStream(); int b = -1; while((b = dis.read()) != -1) { out.write(b); } out.close(); /code My question: is this approach more expensive than simply retrieving the file? If so, is it significative? Best regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: shared/classes folder
In order to share objects between webapps, you need a common repository. This is what shared/classes or shared/lib is for in tomcat, and that's why there's only one copy there. This is correct behavior. (Yoav Shapira) Oh. I didn't know about that. Are there any docs about this? I'd like to see more. Personally, I'd suggest you put everything under WEB-INF to keep your webapp self-contained and portable (Yoav Shapira) Self-containment is absolutely required, because the apps are to be deployed in different servers (therefore making the shared/classes folder unusable). Anything you need to exchange with outside apps can be done in a variety of other ways, e.g. XML documents, pinging URLs, JMS messages... (Yoav Shapira) I'm using XML. I don't know JMS messages, but i'm glad you mentioned it, i'll see more... Thanks for your help! Best regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
shared/classes folder
I'm developing a set of applications which need to exchange objects and are to be deployed in different servers. During development, i use just one server, and put all the common packages under the tomcat/shared/classes folder. All applications have their own memory space, so if i use an object (like a static class) in one application, it is different from the same class in another application. But, for classes under tomcat/shared/classes, the objects are the same! That is, classes are loaded into the same memory space. Is this behavior correct? It doesn't seem logical... If so, is there any way i can prevent this? Best regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: error-page directive
Which versions of IE is that applicable to? (Graham Reeds) Sorry for the delay. IE v 6.0.2600 Regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: error-page directive
I recall there was an issue with some version of IE: it had a feature: if the error page is less then x bytes then IE showes its ugly default error page. But if the error page is large enough (in terms of bytes) then it showes that. (Anton Tagunov) You are right! IE shows its default error page if the messages has 341 chars or less. From 342 chars up, it shows the received data. Thanks! My problem is solved. Please let us know if this works. If it does it is worth adding to the faq. I agree. Explaining IE's behaviour should clarify all. By the way, Netscape doesn't do this... Best regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
error-page directive
I am using Tomcat 4.1.24 in Windows XP and I cannot define an error page. I have defined it in web.xml as error-page error-code500/error-code location/errorpage.hmtl/location /error-page and none of them works. The page displayed is Tomcat's default error page. The error-page tag seems to be simply ignored, as no errors are found in the application initialization. If I use error-page exception-typejava.lang.Throwable/exception-type location/errorpage.html/location /error-page and throw an exception, like RuntimeException, IE shows it's default Error 500 - Internal Server Error page. I tried to put errorpage.html both in the server's root and the application's context root. It doesn't work. I tried switching the location for a servlet mapping, like /error. It doesn´t work. I upgraded Tomcat to 5.0.12. The result is the same. So, what's the problem? Regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: error-page directive
Howdy, You may also have to disable Show Friendly Error Pages (or something similar) in Internet Explorer's Internet Options pages. (Yoav Shapira) Thanks. That worked fine, with both error-code and exception-type. It is not the best solution, though... users have to change their configuration. Isn't there another workaround? If this is a cut'n'paste job from your web.xml page then the problem is you have defined a .hmtl and not .html file. (Graham Reeds) No, it wasn't cut'n'paste. Sorry about that... Regards, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: error-page directive
Instead of worrying so much about the appearance of your custom error pages, try to code your app not to get as many errors ;) (Yoav Shapira) Nice one there :) I do, but i wanted to make sure no error message with stack traces is sent to the user. And I use RuntimeExceptions for those impossible situations, which end up happening. Thanks again, Carlos Pereira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]