ing erl

+ Follow
since Jan 27, 2006
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 ing erl


Trying some examples here in 'head first servlets & jsp'.
using JEE 1.5,EL and JSTL.
I am using a form that is doPost.

Wanting to turn off the cookies and do everything myself with
the sessionid - seems difficult to me.
Trying to follow the MVC schema that my Servlet is my controller,
and that is where I should be handling my sessionid.

Using the 'HttpSession session = request.getSession(true);'
in my Servlet, reading on URL rewriting but not quite getting that.
Seems that the cookies are the default, because I get the values
that I except using cookies ...

using the following:
if ( session.isNew() ) { // Session created for the first time ...
} else {

then doing the 'String jSessionId= session.getId();'
should I do some rewriting here? using the response and
do some rewriting and then using the dispatcher ?

the encodeUrl is deprecated ...
I am not sure how to resend the ID to the client everytime,
seen that ofcourse on some sites and I can se that on some sites:

is there a good example somewhere ?

regards, i
13 years ago


Would like to use your:

Just not fully understanding it, the fault is mine however.
I can see that this is the right way to do things.

are there any good examples to find regarding your example ?
let say I have four buttons / 'previous','next','first' and 'last'.
how do I write out the names of the button in a console ?

regards, i ( still morning, so, a cup of coffee might do the trick)
14 years ago
Thanks Brian,

Must check that out.
Did try your example, but where does the event fly ?
IF I would like to write out the 'ok' or 'cancel' in the console
after pressing, how do I do that ?

The KeyListener-interface gives me they below method:

And here I am able to check if Enter has been pressed by doing:

But still I do not know if the 'ok' is in focus or if 'cancel' is in focus.

Still I found the ability to fetch the source of this event by using the following:

which gives me the text written on the button

the lot would be like this:
public class MyNewListener implements KeyListener {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER
&& e.getSource() instanceof AbstractButton)
System.out.println(" button "
+ ((AbstractButton) e.getSource()).getText()); }

this is working for me, but is this the best way to do things.
I am now able to create a 'MyButton' class that extends JButton and
adds a Listener that handles all my 'clicking'.
using this approach gives me some other stuff to deal with,
for instance from which OK button I am coming from when using
several Panes ( using TestingTabbedPane ) - but that could
ofcourse be solved using the listener above as an Inner-Class and
getting hold of the actual pane-title ... do not want to use a static ...
for some reason.

regards and thanks for your reply,
checking the appendix first thing in the morning.

regards, i
14 years ago

Well creating an inner-class like this:

I only get to know if I have punched the 'enter'-key on the keyboard,
but I do not know if I have tabbed to the 'ok'-button or the
So how do I detect if the 'ok'- or 'cancel'-button is in focus ?

someone said that I should use mnemonic .... but is that the right
way ?

regards, i
14 years ago

Did create a small example where the user
is prompted to add firstname and a lastname.
at the bottom are 2 buttons 'OK' and 'Cancel'.

Using the 2 Inner-Classes to detect whether the user
has clicked with the mouse ( using a class that implements ActionListener)
on either button - that is working fine - and testing if the user
has pressed 'enter' when either button is on-focus ( using a class that
implements KeyListener ) - but there I only detect if 'enter' has been pressed, and not knowing if 'OK' is pressed or if 'Cancel' is pressed.

Which approach should I take here, having the book 'java swing' from oreilly on my desk but not finding anything that could help me.

regards, i
14 years ago

Using Local interfaces with the annotation @EJB.
Is that only possible to use from other Enterprise Javabeans.
I am not able to use the @EJB from within a servlet
though the servlet is running in the same JVM as the EJB ?
When using an EJB from within a Servlet I must always use 'lookup' ?

regards, i
Hello Shailesh Kini!!!

You saved me here, thank you so much.
Well, one is puzzled these days; I bought 3 pair of books regarding EJB 3.0.
Everyone of them has so many errors that you loose faith in the end.

The O'Reilly where the example is from, here is their ejb-jar.xml file:

So, from this example - how am I to know that this is the wrong way to do things ?
As you said, I had it all from the start with the '@Local' annotation.
My ejb-jar.xml is only these few lines:

And it is just for the sake of testing.

So I am very greatful for your help.
Are there any books out the covering EJB 3.0 for a newcomer in the Enterprise JavaBeans world in the sence that I am not coming from EJB 2.1, but from J2SE ? A book where nothing is taken for granted?

Going to follow this up by looking at JMS and Transactions, within EJB 3.0.
If you have any tips regarding the subject, you are welcome.

regards, i
[ October 12, 2007: Message edited by: ing erl ]

Just wondering, when starting JBoss 4.2.1 I get the following information:

[AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path:

So, which native library will give me an optimal performance ?

regards, i
14 years ago

My environment is:
Using JBoss ver. 4.2.1 and %JAVA_HOME% IS 'C:\Program Files\Java\jdk1.5.0_12', my JRE is 'java version "1.6.0_02" ' which should not cause any harm.

Reading Debu Panda's article on DI from 2006 on ONJava.
Still, having problem using the @EJB.
The example in Pandas article ( page 4 ) is like this:

He never tells where the ProcessManager is coming from, it must be from a ejb-jar.xml ( or another DD ) - but how is the syntax ?

Another example:
From O'Reillys workbook (Enterprise Javabeans 3.0, 5th edition ) there is an example of a Stateless 'TravelagentBean' that is using 'ProcessPaymentBean' which implements both a Local and a Remote interface ( ch. 11_5 ).
The 'TravelAgentBean' is using 'ProcessPaymentBean', and the code within the 'TravelAgentBean' is like this:

and the ejb-jar.xml is like this:

But the syntax is not correct.
I am getting the following error:

And finally:

is there an obvious answer here or am I totally missing the point ?

regards, i

My ejb-jar.xml starts with these lines:

Is this the correct information to my JBoss ?

[ October 12, 2007: Message edited by: ing erl ]

[ October 12, 2007: Message edited by: ing erl ]

[ October 12, 2007: Message edited by: ing erl ]

[ October 12, 2007: Message edited by: ing erl ]
[ October 12, 2007: Message edited by: ing erl ]

I am currently reading the Apress-book 'Beginning EJB 3 application development, from novice to professional' and 'PRO EJB 3 API ...' from the same company.
The examples are not that good in those two books, the authors were probably in a hurry and did not get everything into the books.

I am using jdk 1.5 and JBoss 4.2.1 if that should matter.

One thing that I cannot make happen, is how to Add an Item to a @ManyToMany - relationship. The key word is 'Add' here.

Found an example <a href="</a rel="nofollow">" target="_blank">[/url]
but the exmample crashes in more than one location.
The relationship is ;
Homes has many Persons, and a Person can have many Homes.
The tables are simple HOME has an 'ID' and a 'STREETADDRESS', PERSON has
an 'ID' and a 'NAME', a middle table is created HOMEPERSONS ( with PK from HOME and PK from PERSON). All tables are created.

There are 2 Entity-beans, Home and Person.

The Home-bean has the following statement (excluding all others ):

and Person has the following statement (excluding all others ):

The example states that we only need to do the following to add Home and a Person and that the middle-table is filled in some way.
This is their example:

Am I doing something wrong, or are they missing something important at '' ?
Hope that you can help me out here, cannot consider myself being able to handle this technique if I do not know how to insert a @ManyToMany.

best regards, i

Thanks for your reply.

Looking at my datasource which is configured in mysql-ds.xml and persistence.xml, I am able to access the handle to my database through an injection instead of a JNDI lookup like this:

Can I not do the same thing regarding my Local interface, or is the correct and right way ( maby the only way ) to access it using a JNDI lookup ?

Any ideas on how I could explain Context / InitialContext in the best way ?

regards, i

Writing a tiny EJB 3.0 example here;
the application has 1 session bean acting as a facade, 1 entity bean matching a table within my database.
Creating a Application-client (main-method ) with a file which has the following content

java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces

I am able to fetch my Session-bean, with the code down below, which implements an Interface which is annotated with @Remote.
this is the code:

The example is working, and I am able to fetch the content of my database-table.

Wanting to perform the same operations using an Web-client.
For that task I create anservlet and within the doPost-method I want to fetch the reference to my EmployeeBean.
Should I not let my bean implement a Interface that uses the @Local annoatation ? due to the fact that my bean and webclient-app is floating around within the same Application Server ?

If you wanted to explain the InitialContext to me, not just referring me to the API but rather to an article or a book! *S* , how would you explain that - am I getting trhough to the containers-environment here ?

I am running JBoss 4.2.1, running Eclipse Europe 3.3 ( if you have any further tip ... )

Best regards, i
Thanks for the reply!
Start looking there!

regards, i
15 years ago

Being puzzled.
I am not quite sure to handle my problem, not knowing where to start.
I have a dll written in C or C++, a speech engine from a third party, that I want to access from Java.
How do I access those C functions from my Java code, will I have to
write som kind of 'adapter' using JNI as some kind of middle-layer.
Are there any godod articles on the subject besides the Tutorial on the site ? or books ?

Using Netbeans for coding at the moment, is there any kind ( if there is use for that) of plug-in regarding problems as this ?
Could switch to any other kind of tool here, if it helps me.

regards, i
15 years ago

Doing this tiny desktop application, connection to a database with eight
up to ten tables in it.
using matisse in netbeans 5 and using the derby database from apache,
deploying it all in one package ... wanting to keep it that way.

today, the code I use when writing object to my db is quite ugly,
Strings of SQl are stored in one class ... and I am forced to do some
tweaking. Not using views nor stored procedures yet in the db.

is JDO the right path for me to go, simple enough for this project ?
or should I go the hibernate way, or is the learning curve to steep here ?

could you give me some advice here, would like to do this in a
simple yet a nice way ...

best regards, i