?
Solved

java servlet problem in java script.?

Posted on 2003-04-01
9
Medium Priority
?
1,294 Views
Last Modified: 2012-06-21
hi everyone!
the problem is that i want to call a servlet from a java script code ..
in the jav script i've written the function which is called on the onclick event of submit button.
iam not able to to get my servlet page from that function call.
plz help me out .
the code is like this..
<script>
        function submit_db()
        {
        }
</script>

<input type="submit" value="Submit" onClick ="submit_db()" name="B2">    
what do i write in the function submit_db() to call my servlet
0
Comment
Question by:ombhai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 4

Accepted Solution

by:
thanassis earned 252 total points
ID: 8245553
put an action at your form e.g:

<form name="form1" method="post" action="step2.jsp">
...
<input type="submit" value="Submit" onClick ="submit_db()" name="B2">    

...

and in your script

<script>
       function submit_db()
       {
         document.form1.submit();
         return true;
       }
</script>

0
 
LVL 5

Expert Comment

by:burtdav
ID: 8245583
you shouldn't even need the onClick or submit_db()
0
 
LVL 6

Assisted Solution

by:jarasa
jarasa earned 248 total points
ID: 8246247
Well if you have a form with some Input values wich you want to send to your servlet you should put and Action on the form pointing to the servlet and then call the submit() from the script as thanassis said.

If you just want to call the servlet with no form just make your validations on the script and redirect the URL from the script:

<script>
fuction sendRedirect() {
//Validations
.....
//Redirection
Document.location.href="your servlet address"
}
</script>

Have fun
Javier
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:ombhai
ID: 8250738
thanks a lot the problem is solved
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 9400225
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

<note>
Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>

If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp


Cd&

0
 
LVL 5

Expert Comment

by:burtdav
ID: 9401708
To me, ombhai's final comment suggests that an A grade should be given. I think jarasa's answer is best.

Recommendation: award A grade to "Comment from jarasa  Date: 04/01/2003 07:14AM PST"
0
 
LVL 6

Expert Comment

by:jarasa
ID: 9403966
Hi.

I should ask ombhai how did he solved his problem I guess thanassis aswer is as valid as mine and his/her asnwer was before mine.

Javier
0
 
LVL 6

Expert Comment

by:Programming_Gal
ID: 9712121
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between jarasa and thanassis

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Programming_Gal
EE Cleanup Volunteer
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question