Win a copy of Spring Boot in Practice this week in the Spring forum!

Ben Roy

Ranch Hand
+ Follow
since Nov 01, 2000
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 Ben Roy

A little confusion here on my part:
Following up on a question I had below, I have an ArrayList of cartItem objects. Each cartItem has a qty property, which may need to be updated.
cart.updateQty(cartItem myItem, int qty)
{
}
What I'm trying to figure out is how I can update the qty if the cartItem already exists in the ArrayList. For example, in C++ I'd just reference that particular cartItem in the ArrayList and set the qty value. But I don't think java has references. So if I do this:
//First line returns a cartItem
itemToUpdate = cartList.get(whateverTheIndexIs);
itemToUpdate.qty = newQty;
itemToUpdate is a copy of the item in the array, right? So now to have the updated on in the arrayList I need to remove the one in the array list and insert itemToUpdate? Is that how it works?
20 years ago
I'm trying to figure out what I should use to implement a shopping cart. I've got a class that implements a product instance, and I want to have add() and remove() and updateQty() methods as part of my cart class. What I'm trying to figure out is what class to use to keep the list of products in the cart. I've been looking at all the different lists and collections and frankly I'm lost. Something quick and easy to plug into my cart class would be ideal. Also, I will need to alphabetize them, so I was looking at classes that use the compareTo() method, which I have implemented in my product class.
20 years ago
How do I do a jsp:forward to a dynamic address? I was thinking the tags had to be static.
20 years ago
JSP
I'm not sure how to clear the buffer.
20 years ago
JSP
Following some advice I saw on a msg board somewhere else on a related topic, I changed the url's in the redirects to be absolute url's. Someone was mentioning a bug in mod_jk (sits between apache and tomcat) that makes it not track session ID's correctly on relative urls. I'm not convinced it fixed everything, but it is definitely working much better. More information if I figure anything else out.
20 years ago
JSP
This is a little complicated to explain, so please bear with me.
Short list of steps of what is happening:
1) On the main page (a .jsp), click the login button which launches a new browser window with the login pages
2) Type in information and submit
3) The page reloads, checks the authentication info (via a javabean), and if successful, uses a response.sendRedirect() to forward it to a close page
4) The close page uses javascript to send the main window to a new page and close itself
Here's where the problem comes in. When the new page loads in the main window, I end up with the entire body of the login page, plus the text at the end of this message, plus the page it is supposed to be displaying. All in one. It seems like on the redirect it is sending all of the html to the buffer, even though I redirected before the html, and then the next page you go to it is writing it all to the screen.
First thought whenever the buffer comes up is "flush the buffer!" But I don't want to send that information at all...that's why I have a redirect. As a side note, I did try to flush the buffer, and it acted just the same. Here's the text that is inserted after the body of the login page and before the body of the page it is redirecting to:
HTTP/1.1 200 OK Date: Wed, 12 Dec 2001 21:25:29 GMT Server: Apache/1.3.12 OpenSSL/0.9.6a (Unix) ApacheJServ/1.1 mod_jk Servlet-Engine: Tomcat Web Server/3.2.3 (JSP 1.1; Servlet 2.2; Java 1.3.1_01; SunOS 5.6 sparc; java.vendor=Sun Microsystems Inc.) Keep-Alive: timeout=5, max=14 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html;charset=ISO-8859-1 ffb
Also I should note that if you refresh the page it comes up correctly. Some other links on the site will sometimes (apparently at random) display the wrong page or parts of other pages. Again, a refresh always fixes them.
HELP!
20 years ago
JSP
Well I did have this running on my dev system (Win2k with Jbuilder) which I believe is using tomcat. I never experienced any of the above problems on that machine. I also have another app that has the same pop login setup as this which is working fine deployed on Weblogic/Solaris. I agree, it is something specific to this server, but I still have to make it work =P
20 years ago
JSP
I have a javabean I'm using for logins. It is set for session scope. The top of each page is printing out the session ID. Here's what's happening:
>Main page loads. SessionID like: 9wlk1fck81
>Click on 'log in'. New window pops up with user/pass fields and sessionID like: 9wlk1fck81
>Type in username/pass and click submit. Login window submits to itself, authenticates, and redirects to an HTML page which has a 'opener.location.href="newPage"' line of script. It then closes itself.
>The new page that is in our original window now has a sessionID like: wl143fkdiow2
How in the heck can the sessionID on the same server in the same browser window change? At no point am I forcing the session to end or anything like that. Obviously it is causing problems because the user is logged in the original session, not the new one that it redirects to.
Platform is tomcat/apache on Solaris. Browser = explorer OR netscape on a win xp/2k or mac.
20 years ago
JSP
Is there any way to access session javabeans in a servlet? I often track user logons via a javabean, but this presents a problem if I want to use servlets. I hate to keep passing the user's ID and permissions through the query string, but right now I have no other way to do it.
20 years ago
I think we're still missing something. Let me walk you through a scenario:
Customer_A logs into the web site via Internet Explorer. Let's say the web server is at my site. Customer_A goes into the products administration page and clicks on "add". A form comes up which has fields for product name, description, price, etc. There is also an image field. Next to it is a browse button. They click browse, navigate to the image on *their* computer, then submit the form and the file is uploaded to the *server*. What I'm trying to figure out is, on the page that the form submits to (jsp or servlet) how can I receive that file out of the request object.
20 years ago
How do I read a file in from the request object?
20 years ago
I have an administration page for a site where I need the user to be able to upload an image from their local drive. Can someone give me some direction on how to do this? I can get as far as putting in a browse button and letting them select the file, but how do I handle this on the server side?
20 years ago
At first I was thinking of finding the word, then checking the char before and after it to see if they were spaces. But then...if I just checked for " " + myNaughtyWord = " " in the first place, I could save a lot of yucky mucking around.
20 years ago
That is essentially what I have implemented for now. Turn's out the really interesting part of the problem is in filtering out legitimate words that contain naughty ones. Like glass, bass, mass, etc. All of those words are ok, but under the filters we've discussed here the posts would be blocked.
20 years ago
I'm trying to implement a language filter on a message board. Essentially I'll have a list of words in a database that are flagged as inappropriate. I need to search the incoming string from the post for those words. I only need to detect if any of them exist. Of course, I can just search on each individual word with a while loop, but that seems really inefficient. Is there any way I can search a string for ANY of say 10 different words?
20 years ago