Pat Wallwork

Ranch Hand
+ Follow
since Sep 23, 2001
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 Pat Wallwork

Awesome!
I am not a frequent poster here but I certainly browse the forums often. I've recently began utilizing Hibernate and I'm very impressed with it, although I've only just used the basic features so far. I look forward to viewing the topics and discussions here :-)
Here's to a future of great webapps free of all that damn repetitive JDBC code!
-Pat
One thing the html tags do that I like is automatically URL encode your links. I used to hate doing this manually!
-Pat
18 years ago
Bruno,
I agree. Too many times I've taken what appears to be a shortcut in developing only to have it come back and bite me later when the project has grown. I guess it would be the same with this example. That's partly why I'm interested in struts as it kind of enforces the mvc approach. I'll stick to the approach you mentioned and I appreciate your insight
-Pat
19 years ago
Bruno, thanks for the reply.
You point out something I was worried about which is coupling my application to struts (although I do sometimes wonder if that is a bad thing with a small to mid size application). Creating the logic in my Action class just seems to me to be creating some extra overhead as there are more method calls to access the users input parameters so that I can form my sql query...as opposed to doing it right in the ActionForm where I already have access to the input parameters.
I wonder if I'm the only one a little confused on this or if it's a common misconception...but I see advantages and disadvantages to both sides here.
-Pat
19 years ago
Hi,
I am experimenting with struts on one of my projects a little and not sure if I'm utilizing it properly yet. I have one page that has a lot of form fields that users can select from to perform a 'detailed search' of my database with. I find that since I'm validating their input in the ActionForm already it seems like a good place to setup the sql query too. So, if their input passes validation then the ActionForm puts together the sql query as a String and I then grab it from my Action class for further processing.
This seems the easiest approach to me so far, but I'm not sure that it's a good idea to be performing some of the business logic in the ActionForm. (I'm also not even sure if that would be considered business logic anyways!) Any thoughts would be much appreciated!
-Pat
19 years ago
From the api:

A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.


So in your case you should have 2 separate statement objects.
-Pat
Wow...then I really do have to take a look over all my previous apps to ensure thread safety! Most cases will likely be ok as they are beans stored in the users session, but in the future I think I'll stick to declaring variables in methods only then!
Thanks for all the info, I'm glad I learned this now before disaster struck!
-Pat
19 years ago
Hey Ranchers,
I just got thinking about my above question again and I'm still having trouble understanding this. If I use a bean like this:

my understanding is that foo is an instance variable and is Thread safe. If that's correct, why is my above example not?
Thanks in advance...I really want to get a firm understanding on this issue!
-Pat
19 years ago
ugh...I did not want to hear this. I took over a project that does this in several classes. Most of them are for admin screens so there is little worry of 2 people accessing them at the same time...but there are a couple of classes utilized by the public that do this as well.
If this is absolutely certain...then I guess I have to rewrite these pages so all variables are declared within methods, as I do not want to use synchronization. DOH! *shaps forehead*
Oh, and sorry if I did post in the wrong forums. 10 sensible replies coming up
-Pat
19 years ago
Hi ranchers!
I have trouble understanding whether this is thread safe or not...and I hope I'm posting this in the right forum. In some classes or servlets I find it easier to declare variables without instantiating them so I can use them within any method in the class. By doing this though, I worry that if 2 simultaneous connections occur that they may both be sharing the same variable. Here is an example of what I mean:

Whether the above example is a servlet or a helper class and if thread safety is paramount...is this dangerous? Talking to some programmer friends I get conflicting answers on this so I really would like a clear definition. Even in the books I have on Java this is clearly not defined.
Thanks for any insight on this!
-Pat
19 years ago
You definitely don't have to use servlet mappings if you set your init-param's in your web.xml like this:

then to call it from a jsp you just use:
getServletContext().getInitParameter("name");
-Pat
19 years ago
JSP
DC,
I thought I'd check that site you suggested but either the link is wrong or the site is down.
If the link is right that cannot be a good sign! :roll:
-Pat
19 years ago
Robert,
I do this sometimes in my jsp pages as well...the easiest way I found was to do this in your jsp:

hth's,
-Pat
19 years ago
JSP
I reread your question and understand what your trying to do now. Tom's suggestion sounds good. If your not checking for a query string then your servlet will keep redirecting the client resulting in that endless loop.
Another idea might be to use the session.

-Pat
19 years ago
Is the ? included in your querystring? If not, try this:

hth,
-Pat
19 years ago