Desired output
Index.jsp
form3.jsp
test.jsp
Desired output
Click image to zoom |
Index.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src="commonfunctions.js"></script> </head> <body> <%@ include file="form3.jsp" %> <input type="button" onclick="openWindow()"> <!-- since form3 is included we can access the function written in hat page --> </body> </html> |
form3.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src="commonfunctions.js"></script> </head> <body> <script> function openWindow() { alert("form 3 jsp"); var output ="<parent><tag><string>rahul__1</string><string>abcde__1</string></tag><tag><string>rahul__2</string><string>abcde__2</string></tag></parent>"; document.getElementById("output").value=output; var type="Open_new_tab_from_form"; document.getElementById("type").value=type; window.open('test.jsp', 'TheWindow','TheWindow'); document.getElementById('TheForm').submit(); } </script> <form id="TheForm" method="post" action="test.jsp" target="TheWindow" > <input type="hidden" name="output" id="output" /> <input type="hidden" name="type" id="type" /> <input type="hidden" name="name" value="Rahul" id="name" /> </form> </body> </html> |
test.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>New Window</title> </head> <body> <%String name=request.getParameter("name"); %> <script> <%String type=request.getParameter("type"); %> <%String output=request.getParameter("output"); %> var output="<%=output%>"; var type="<%=type%>"; var valueOfName="<%=name%>"; alert("output "+output); alert("type: "+type); alert(" name is "+valueOfName); </script> <% out.print(output); %> </body> </html> |
Desired output
No comments:
Post a Comment