This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes java coding problem ~ system.out.println Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "java coding problem ~ system.out.println" Watch "java coding problem ~ system.out.println" New topic
Author

java coding problem ~ system.out.println

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, good day, i have a problem, which is normal java class and calling from struts action class, the coding as below :



problem : when i check the result from tomcat console, it appear double output result ..why is it so ? anyone know it ?

result display in console:

test.jsp not create
test.jsp not create
test.jsp create
test.jsp create

thank you very much for your time !!
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Alvin,
I doubt that the problem is not in the code that you provided above and it could be in the page that make use of this class... Could you provide some more info where you use this class and from where this class is called?

I do hope we can help you more, if more info are provided...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
thanks for reading, ko ko , my action class as following :

Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
It seems like there is nothing wrong in your action class also... What about the HTML page that is calling your action class?

I used to face this kind of problem before... It was the problem with HTML FORM tag. I was trying to call the action class both from HTML FORM tag and JavaScript action, which results in calling the same action two times...

I doubt that your case is similar to my case... Could you check your HTML page again?
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
ko ko , this is my html page coding ..and it is popup form, the popup form consist of 3 page, this is the last page and calling the action

Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Alvin,
I can see the error now...

It's similar to the problem I got before... You are using submit input type, surrounding with a href tag... That could be the problem... Could you use simple button input type? I hope it's solved then...

There are redundant codes in your JavaScript also... In submitFunction(i), you are checking the value of i... I see only one call submitFunction(2) to get back to previous page... So why don't you fix the method only for getting back to previous page? Other actions have their own fixed method to go...

Hope it helps...
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, ko ko , if i do not use href tag , i couldn't put multiple button which call multiple action ...how i solve this problem ?

do you mind to modify my existing html code base on your explanation ? i have little confusing then ...

thank you in advance for your valuable time , really appreciated !!
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, ko ko , i have modify as below but it seem not help :

Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Alvin chew:
hi, ko ko , if i do not use href tag , i couldn't put multiple button which call multiple action ...how i solve this problem ?


Yes, Alvin, you can do that... Put multiple normal buttons, not submit buttons, which might cause double submitting...

Change every input type = "submit" into input type="button"

Hope it might help you...
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
I think, move this topic into Web Application Framework.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
thanks , ko ko ...i solve it .....highly appreciated your sharp eye on my mistake...fantastic ...

anyway, since the popup form have 3 page .. i change in all pages but i using input="submit" ..it still function ...anyway ...i try input="button" now ....once again ...thank you !!
 
GeeCON Prague 2014
 
subject: java coding problem ~ system.out.println