Eduardo Moranchel

+ Follow
since Jul 31, 2012
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Eduardo Moranchel

One way to do it (besides trying not to take too long on this kind of processes) is calling another page/servlet/jsp that will in turn call your heavy load servlet and display appropiate feedback to the user.

Here is how.
Lets asume right now you have 1 page and a servlet.
Page 1: form page (with a button to:)
ProcessHeavyStuffServlet (our slow servlet)

We have to change this by adding a couple of things. like this:

Page 1. Form page (user fills stuff and clicks next which is the heavy load stuff)
We replace the ProcessHeavyStuffServlet link with a link to a waiting page.
Page 2. Waiting page (new page)
Here we have a waiting image and we call the ProcessHeavyStuffServlet using AJAX or an IFRAME (i know they are ugly but sometimes useful)
We modify this one to store some data in the session (like the results of the execution) at the end of the execution it will tell the waiting page (using AJAX or in the IFRAME using a parent call) to go to:
page 3. Results page (new page)
We get the data that ProcessHeavyStuffServlet stored in the session and display it.

This is the theory behind those beautiful and annoying "please wait" sliders and gizmos.

Hope this helps, good luck, have fun.
8 years ago
actually you only need a lot of string parsing.
But here it is how you usually do this:

is not the best code (i know) but should point you in the right direction
Also where the system.out.println is is where you need yo add the string to a collection to return it or call directly the insert in the jdbc.
The way i understand it:

A thread local is a class.
It has a value per thread.
It is a key/value store where the key is the Thread ID and the value is whatever we put inside
Wait. is it... like a map?
maybe. lets think it this way.
All threads have a unique ID, that can be the key of the map.
And we store a value inside.
So we can say a ThreadLocal can be actually a Map<ThreadId, ValueType> variable.
but handling maps and stuff is bad and boring so why not disguise it with ThreadLocal<ValueType>
ok now then how do we get the id?
Thread.getCurrentThread().getId ? something like that exists actually.
So there you have it. how ThreadLocals work.

Being static is just in case you want to access it from different objects regardless of where they are (a convenient way of passing the variable around) but is in no way mandatory.
The new Tiobe index for this year is out.

Not to help the argument, but I wonder why java went down from being the king.

Also noteworthy: Java has been in top for most of the years competing with c with clear advantage.
People use it, and will probably keep using it, but anyway.

What are your thoughts on this?

8 years ago
Can you use external libraries? if you can then get the Apache commons lang jar.



Inside there is the StringUtils class which does what you need

Its full of static methods to test and modify strings you will be amazed of how much stuff you can do with it.

8 years ago