Steve Simon

Greenhorn
+ Follow
since Jan 28, 2012
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 Steve Simon

I am using Glassfish, and am attempting to write files to disk from a web application.

Unfortunately the file is written directly to the Glassfish server directory ("C:\...\.netbeans\7.0\config\GF3\domain1")
and not to my project directory (which is where I want it to be saved to).

For Servlets, I got around this problem, using the following method:
String filepath = getServletContext().getRealPath("/");

But for my web service, I cannot use this method, and am struggling to find one which would work.
Does anyone know of a method which might help?

Thanks very much


11 years ago
Ok cool thank you very much to both of you, I really appreciate the attention.

The Java tutorials are indeed great, so I guess I should rather look at them more often than stick with my current preference: looking at the source code (which, by the way, involves such 'tight-coupling' of classes and interfaces its just bewildering to trawl through!)

Take care

regards
Steve
11 years ago
Thanks guys,

Campbell, the key-bindings are definitely relevant to my needs and I had no idea there was such a thing.
That certainly solves a big part of my problem, thanks for that.

Michael, you're on the right track.
In actual fact, it is currently the solution I am using for my custom component, but I would really like to simplify how it is used.
The problem is that this approach is implementation specific. Every time I use the component, I need to remember to intercept all related low level events and call doSomething() from them.
This would be fine if I didn't plan to reuse this component regularly, and I will be using this component regularly.
So what I actually want to be able to do is group all related low level events and define that group as an "ActionEvent" or even "MyCustomEvent".

Hypothetically, I would prefer to say some thing like: "A mouse release, tab key, mouseWheelMove should be treated as one kind of event, called "MyCustomEvent". The only thing you need to do when using this component is to intercept "MyCustomEvent".

Is this possible? (sorry if I wasn't clear enough before)
11 years ago
Is it possible to translate a low level event (such as MouseEvent or KeyEvent) into a semantic event (such as ActionPerformed)?

To simplify my question, is it possible to fire an ActionEvent as a consequence of a particular key being pressed?

Thanks in advance.
11 years ago
This seems like what I was looking for.

Perfect, thanks very much indeed.

regards
Steve
11 years ago
Hello all JavaRanch contributors.

Searching through the other Forums on Web Services
I am a little embarrassed to ask such a simple question,
but everyone has to start somewhere I suppose.

I just started learning about JAX-RPC for writing Web services
and using Ant to build a project with a build.xml file.

PROBLEM 1:
I have to admit, for the first time in my Java course I am
completely confused as to the purpose of these tools and
in what context they are useful. The text book simply makes
a brief comparison between JAX-RPC and RMI and then jumps
into the example without a satisfactory explanation.

PROBLEM 2:
I am struggling to get the example in the textbook to work.
Unfortunately, the text book is now about 3-4 years old,
and I gather that a fair amount has changed since then.
For example, the System Application Server Platform
has been superseded by Glassfish server. I cannot
download the old product and the textbook describes
many configuration settings using the System Application
Server Platform installation wizard which concerns me.

HOW YOU MIGHT BE ABLE TO HELP:
Can any of you point me to a "Hello Word!" type example
which is relatively up-to-date. In addition, could you point
me to a good explanation of how JAX-RPC and Ant and
could be used (in a real world context).

Thanks for your attention.

11 years ago
Thanks Stefan, using different browsers does the trick :)

Actually I think what was confusing me right in the beginning was the way that Google Chrome was handling my application (so this was more of a browser issue than anything else)
I realised that Chrome keeps the session running in the background even if you close the browser completely. So if you launch the application again (before the maxInactiveInterval is reached) the previous session will be restored.
Although this can obviously be resolved by using the setMaxInactiveInterval() method on the session object, a cleaner way is to go to advanced options and:
- 'under the bonnet', deselect 'continue running background apps when Google is closed'.
- go to 'privacy' and 'clear browsing data' (make sure 'delete' cookies' is checked).
Alternatively, you can just redeploy your application every time.
I just checked, and neither Firefox, nor IE have this problem by default.

But, its good to hear from people who probably have more experience than me that a particular requirement (such as the one I was looking for) is probably not a 'realistic requirement'.
It was just annoying when I was trying to test the application and I wasn't getting 'fresh' beans each time...


12 years ago
JSP
Hi Rob, thanks for the response.

I think where I got confused is that I assumed that the [application server/ JVM / whatever entity is responsible] would create a new session every time I open the same website from the same computer.
As it turns out, the session continues to remain active because the same bean is used.

HERE IS A SIMPLE EXAMPLE:

THE BEAN


THE JSP


If you run the above application, and click the reload button on the browser 2 times. The number increments by 1 until it gets to 3.
Run the application again (opening up a second tab on the browser), and click the reload button 4 times. The number increments by 1 until it gets to 5.
So far so good.
Now, go back to the first tab that was opened and click reload.
The number now jumps from 3 to 6.

This illustrates to me that the same session (and bean instance) is being used by both tabs.

Am I correct in saying that the application server or JVM can provide maximum ONE session for each client?

Thanks again!


12 years ago
JSP
Hi guys,

THE SITUATION:
I am following an example in a college text book.
The example is a simple web application for a online bakery.
Basically, you have a jsp showing a selection of baked goods which have been read from a database.
If you click on one of those items (which is a hyperlink), it adds the name of that item to
a 'cartBean' bean and reloads the page to display a table (the Cart) with the newly chosen item inside.
New items can be added to the cart in the same way, and the cart will accumulate all your chosen items.
Its really very simple.
Now, the example suggests (and I presume) that the only way to ensure the cartBean keeps
its contents (without being emptied) is to ensure that the scope="session"/"application".
If scope="page" is specified, a new bean instance will be created every time an item is added
to the cart meaning that there will only ever be max 1 item in the cart at all times.

THE PROBLEM:
Since the cartBeans scope needs to = "session", it means that the same cartBean
session is shared between multiple users! So, if user A loads the web page, and adds three items
to their cart, and then user B loads the web page, user B will see those three items have already
been loaded into their cart even though their cart should be empty.
I understand that bean sharing may be useful (at times), but in this case it is not what I'm looking for.

WHAT I'M LOOKING FOR:
I want a new bean instance to be created for each user. Furthermore, is it possible to destroy that
bean instance when a user leaves the web site?

I sincerely apologise if this has been covered before. If so, please forward me in the right direction.

Thanks
12 years ago
JSP
I can say, with absolute certainty that this is a 64 bit issue.
Rolling over to a 32 bit OS is the only solution I have found.

I must say this driver is VERY annoying.
In fact, I received the same error message when attempting to add another (unused) argument onto the method to which the SQL statement belonged.
If that doesn’t blow one’s mind, I don’t know what does!
Hi. I am using the same text book.
Here is the link if anyone wants it: http://linux.softpedia.com/progDownload/Mckoi-SQL-Database-Download-673.html