Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML JSP
I have a jsp page given below
 
<%@page import="newpack.SendMailJavaToXsl07022013"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
            <%!                SendMailJavaToXsl07022013 oaa = new SendMailJavaToXsl07022013();
            %>
            <script language="javascript" type="text/javascript">
 
                function Button1_onclick() {
                <%
           oaa.mainClass();
           out.print("Sdasd");
           System.out.println("In getDate() method");
                %>
                    }
            </script>
    </head>
    <body>
        <input name="send mail" id="Button1" type="button" value="button" onclick="return Button1_onclick()"/>
    </body>
</html>
 
I expect function Button1_onclick() execute only after clicking Button. But it execute when page loads, and never execute when Button click.
What is wrong in this code?
Posted 13-Feb-13 18:21pm
gavkk1.6K
Edited 13-Feb-13 18:29pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Javascript is a client side scripting language and JSP is a server side scripting language.
So JSP loop will already be executed on the server side.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Javascript is a client side scripting language and JSP is a server side scripting language. So JSP loop will already be executed on the server side.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Javascript is a client side scripting language and JSP is a server side scripting language. So JSP loop will already be executed on the server side.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100