Daniel Dalton

Ranch Hand
+ Follow
since Mar 20, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Dalton

A couple of things (at least)

1) encapsulation. The thing you are setting/getting may be complex - eg. You might create a getter that formats a Date object into a String for example.

2) By following a convention they enable tools to use reflection to manipulate them without having to know field names before hand. BeanUtils gives some examples.
Not that this has anythingto do with servlets per-se, but yes that will happen. If you check the javadoc for the ResultSet class, you'll see that the next() method returns a boolean to indicate if the new current row is valid or not. You are just ignoring that, and going on to read data irrespective.

try something like the following:

most servers will actually support connection pooling themselves. You should look into your particular servers details to find out how it is set up. Your web app would then access a connection via a JNDI lookup. Certainly you can do this in the Sun One webserver. I'm 99.9% certain that you can do it in tomcat by fiddling with the xml config files - though I've never done it.

Hope that helps,
I'm not sure the container adds META-INF to the classpath. What you need to know to make your app work is that un-jarred classes should be placed under WEB-INF/classes in directories mirroring the package structure as usual and jarred classes in WEB-INF/lib.

The container will then make the classes available on the class path.
Hi Joti - the benefit of putting stuff under WEB-INF is that it cannot be directly served. That is, you can't go to your browser and get the server to list the contents of WEB-INF.

ie

http://myserver/myapp/WEB-INF/foo.jsp

will NOT work. There may be stuff in your JSPs etc that reveals something of the structure of your app that might be used to help compromise security for instance.

You can however reference stuff within your html and JSPs as you discovered.

Does that help?

Actually Akbar, I disagree with your statement about putting JSPs under WEB-INF. Personally, I don't want a user to be able to read the text of my JSP files, and I tend to put the majority of them under WEB-INF for just that reason.
[ February 20, 2007: Message edited by: Daniel Dalton ]
Congratulations - that's a fantastic score!
17 years ago
Congratulations - that's a fantastic score!
17 years ago
c ut is used for writing stuff to the output stream. See c :-o ut. JSP 2.0 supports the EL expression language natively, so you can just stick expessions straight into your JSPs like

for instance. Prior to JSP 2.0, c ut is very useful because it allows you to avoid resorting to scripting so you can put
in your JSP.

Does that help at all?
Instead You could try keeping the Actionform 'dumb' and using a setup Action instead. You can have an ActionForm associated with multiple Actions, so basically, you create an action whose job is to populate the Form with the data you require.

By calling database code from your Actionforms, you're coupling your View very tightly to the data access code, which (in my opinion) is detail it needn't know about.

Does that help at all?
17 years ago
A pass is still a pass - congratulations!
17 years ago
I'm not sure I understand your problem... Exceptions are a mechanism by which normal program flow is changed under exceptional circumstances during program execution. I'm guesing that your problem lies with RuntimeExceptions because they're not required to be caught, and the default behaviour of the JVM will be to pass them all the way up to the top level, be that a J2EE container or the command line for J2SE.

In a nutshell, if you want them logging, you need to catch them and log them somewhere, which from what you've written, I don't think you are doing. As to where to catch and log them, that's a whole different ball-park, and depends very much on the design of your program.

Does any of that help?

Regards,
No, JSTL is something very specific - it's the JavaServer Pages Standard Tag Library, so no - while you may well have built a custom tag, it's not part of JSTL.
17 years ago
JSP
Hi Dinuka - you're absolutely right - sorry for causing confusion, too much haste at lunchtime is my only excuse!
And watch out for the datatype of the page implicit object - it's of type java.lang.Object, which you might not expect (I didn't).
No there's no jsp:import tag. You have 3 ways to import stuff:

1) The page directive: <%@page import file="bhah blah" />
2) The jsp:include element: <jsp:include page="blah blah" />
3) The JSTL c:import tag: <c:import url="blah blah" />

Oh and the RequestDispatcher include method.