• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

In Weblogic, service() being called twice

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
when submit event(Button) is called from a jsp Page, the control goes to the controller( Servlet), and there the service method is called twice.

My scenario is i am setting the hidden type field 'BEAN_COMMAND' in the form 'PRESENTATION', and when 'onSubmit', i am calling page LogController.java (Servlet). Here i am taking the parameter using getParameter("BEAN_COMMAND") in service method. But what happens is, first time i am getting a null, and next time i am getting the actual value.

I donot know y it is happening like this. Can u please clarify my problem.

Thanks,
with regards,
Subrahmanyam.O,
mailid: [email protected]
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you exactly mean by

..when 'onSubmit', i am calling page LogController.java (Servlet).



Do you mean, you use javascript methods for form submit? How do you "call page ..."?

If you post code snippets from your work, someone here may be able help you.
 
Oruganti Subrahmanyam
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yah, i am using JavaScript to submit page.. see the below code

<FORM name="PRESENTATION" onSubmit="javascript: return jumpToBatch()" method="POST">

And in jumptToBatch() function, I am doing

document.PRESENTATION.BEAN_COMMAND.value = strCommand;
document.PRESENTATION.action="<%=SERVER_CONTEXT%>
servlet/LogController";
document.PRESENTATION.submit();

And also in LogController.java, i used service method.
String strCommand = req.getParameter("BEAN_COMMAND");

The service method is calling twice and this 'strCommand' value is getting
null onetime, and the actual value in nexttime.

I have read one of the questions posted earlier, which saying that doGet method called twice when used .css file in 'href' tag.
<link rel="stylesheet" type="text/css" href="<%=SERVER_CONTEXT%>web/css/<%=sCSS_TEMPLATE%>">

IS This could be any problem, please clarify my doubt....

Thank u,
with regards,
Subrahmanyam.O
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the problem may be that you are using the javascript onSubmit() method incorrectly. It is designed to be a validation feature so you can check the entries in the form before submitting. If you return true from it then the form is submitted by the browser, if false it is not.

Therefore your call to form.submit() in the onSubmit method submits the form for the first time and when your function returns, the browser is submitting the form for the second time. Hence doGet is being called twice.

It's been a while since I did any javascript so I'm not 100% sure on this...

cheers, Pete
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pete is right; for the code in <FORM name="myForm" onSubmit="return mySubmitFunc()"> to be executed the form must already be submitting, so calling myForm.submit() from within mySubmitFunc() is probably not what you want.

I don't quite understand why the first BEAN_COMMAND would be null, however; I would expect them both to have a value. You don't need javascript: in the event handler. Remove document.PRESENTATION.submit(); from jumpToBatch() and see if that works.

Jules
 
Oruganti Subrahmanyam
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u for responding,

And I havent found solution for the problem, and i observed one more thing that, the problem is not occuring when i use Mozilla Browser,
i havent changed any of the code that u specified.

Can u please tell me what could be the problem,

Why IE6.0 is giving problem compared to Mozilla 1.6

Thank u
with regards,
Subrahmanyam.O
 
JulianInactive KennedyInactive
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Subrahmanyam,

I don't mean to sound harsh, but the reason it works in Mozilla but doesn't work in IE is, in this case, irrelevant. It's not going to help you solve your problem. Your logic is submitting the form twice on each submit. If it works at all then it's a fluke.

I suggest you change the code as I suggested in my previous post and see if that works in IE. If it does, then test it in Mozilla. If it works in Mozilla too, then problem solved. If it doesn't work for some reason and you can't figure out why then please post again. IMHO there's nothing to be gained from spending time working out why dubious code behaves strangely.

Jules
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic