Yup. I got that. I always read your posts very carefully as they tend to be quite insightful and always helpful. I just wanted to make the distinction between the different types of code that could go into a JSP. And while I agree that all other types of Java code should stay away from the JSP, I feel that the code that is presentation layer specific is perfectly at home within the JSP. Not only that, it is actually preferable to any other alternative that I have employed so far.
Jeanne Boyarsky wrote:Rudy: I meant any Java code. I didn't have any specific code in mind.
Invalid on what basis? Spaghetti code is more difficult to read and maintain than code that is clear and concise. Should we stop writing code that is clear and concise and start writing spaghetti code because it is more difficult?
Bear Bibeault wrote:Arguments such as "it's easier" are invalid.
Correctly, as defined by whom? Winds of fashion have blown over this profession for as long as I've been in it. And as such they don't always blow in the right direction. Please remember EJBs were once "The" technology to do things "correctly". I know you are old enough to remember.
Bear Bibeault wrote:It's much important to do thing correctly, than to do them easily.
Jeanne Boyarsky wrote: What do you think are the reasons people keep writing code in the JSP?
Greg Bag wrote:Hey guys I'm kind of confused on what to learn next. As in, what J2EE technology should I be learning next. My main purpose is for marketability and finding jobs.
I know Servlets, JSP, JDBC
Sandesh Shashidhar wrote:
I have a PDF file in my Webcontent/dir/helpdir.pdf and in JSP page i am trying to download the PDF by calling a servlet
The PDF is located in Webcontent/dir folder
But in your code you are opening the /doc directory
Sandesh Shashidhar wrote:String filePath =request.getContextPath()+"//doc//";
Hi Bear. I'm wondering if select count(*) would really be more efficient than say select username. I'm thinking that for select count(*) it has to read every row in the table no matter what, whereas for select username it will stop searching when the row is found.
Bear Bibeault wrote:
If you only care whether the record exists or not, why fetch all the data with a "select *"? To check for existence a "select count(*)" will be more efficient.
Aryeh just to clarify, the DbUtil class need not be a Servlet, in fact should not be a Servlet, as it will not be interacting with the HTTP client, it will only be interacting with your servlets.
Aryeh Golob wrote:
From this point, I would use a static class, say DbUtil to perform all interactions with the database.
Stefan why do you feel that using the static methods in the DB Access class is sub-optimal?
Stefan Evans wrote:But your mention of servlet context attributes and static classes sound sub-optimal.
I'm curious to ask, if I may, why do you feel that you need a design pattern for something like this? Realistically speaking does it offer something to you that your own solution does not?
Nico Van Belle wrote:
I know how to do this technically (with an interface) but I was wondering .. isn't there a Design Pattern for this?