Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 24th, 2017, 02:22 AM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2017
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get value from frame1 to frame2 with "input type = submit"

Hello everybody!

I just start learning servlet with eclipse and I have stuck on frameset.


I have 3 frames :


===Frame.jsp===
Code:
<%@ page language="java" contentType="text/html; charset=windows-31j"
    pageEncoding="windows-31j"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
		<%@ page import="java.util.ArrayList" %>
		<%@ page import="java.io.PrintWriter" %>
		<%@ page import="javax.servlet.http.HttpServletRequest" %>
		<%@ page import="javax.servlet.http.HttpServletResponse" %>
		<%@ page import="javax.servlet.http.HttpServlet" %>
		<%@ page import="java.util.*" %>
		<%@ page import="javax.servlet.*" %>
		<%@ page import="javax.servlet.http.*" %>
		<%@ page import="java.io.*" %>
		<%@ page import="javax.servlet.http.HttpSession" %>
		<%@ page import="StudyC.HTMLFilter"%>
</head>

<frameset rows="25%,75%">
<frame src="HelloINPUT.jsp" NAME = "HelloINPUT"  noresize ="noresize">
<frame src="HelloOUTPUT.jsp" NAME = "HelloOUTPUT" >
</frameset>

<noframes>
<body>
EMPTY!
</body>
</noframes>

</html>


===HelloINPUT.jsp===

Code:
<%@ page language="java" contentType="text/html; charset=windows-31j"
    pageEncoding="windows-31j"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
		<%@ page import="java.util.ArrayList" %>
		<%@ page import="java.io.PrintWriter" %>
		<%@ page import="javax.servlet.http.HttpServletRequest" %>
		<%@ page import="javax.servlet.http.HttpServletResponse" %>
		<%@ page import="javax.servlet.http.HttpServlet" %>
		<%@ page import="java.util.*" %>
		<%@ page import="javax.servlet.*" %>
		<%@ page import="javax.servlet.http.*" %>
		<%@ page import="java.io.*" %>
		<%@ page import="javax.servlet.http.HttpSession" %>
		<%@ page import="StudyC.HTMLFilter"%>
</head>
<body>
<center><b>INPUT</b></center>

<script language="JavaScript" type="text/javascript">

function validateForm() {
			var x = document.forms['myForm']['uname'].value;
			if (x == '') {
				alert('空です');
				return false;
			}
}

function SetSelectedValue()
{
    var selectedValue = validateForm();
    window.parent.HelloOUTPUT.frmSubmit.txtTest.value = selectedValue;
}

</script>
</head>

<body>
<form name='myForm'

onsubmit='SetSelectedValue()' target = "HelloOUTPUT" method='post'>
<input type='text' name='uname'>
<input type='submit' value='Click!'>

</form>

<%

String uname = request.getParameter("uname");
if (uname == null) {
	uname = "";
}

@SuppressWarnings("unchecked")
ArrayList<String> dataList = (ArrayList<String>)session.getAttribute("PreviousItems");
	if( dataList == null ) {
			dataList = new ArrayList<String>();
			session.setAttribute("PreviousItems", dataList);
}
dataList.add(uname);

if(dataList.isEmpty()) {
	out.print("<br>");
} else{
	dataList.removeAll(Arrays.asList("null",""));
    	if(dataList.isEmpty()) {
			out.print("<br>");

    	} else{
			int i = 0;
    		do{
			out.print(HTMLFilter.filter(dataList.get(i)) + "<br>");
    			i++;
    		}
    		while(i<dataList.size());
    	}
}

%>

</body>
</html>

===C18_HelloOUTPUT.jsp===

Code:
<%@ page language="java" contentType="text/html; charset=Windows-31j"
	pageEncoding="Windows-31j"%>

<html>
	<head>

		<%@ page import="java.util.ArrayList" %>
		<%@ page import="java.io.PrintWriter" %>
		<%@ page import="javax.servlet.http.HttpServletRequest" %>
		<%@ page import="javax.servlet.http.HttpServletResponse" %>
		<%@ page import="javax.servlet.http.HttpServlet" %>
		<%@ page import="java.util.*" %>
		<%@ page import="javax.servlet.*" %>
		<%@ page import="javax.servlet.http.*" %>
		<%@ page import="java.io.*" %>
		<%@ page import="javax.servlet.http.HttpSession" %>
		<%@ page import="StudyC.HTMLFilter"%>
		<%
		out.println("<center><b>OUTPUT</b></center>");
		%>

	</head>
		<body>

		</body>
</html>
Is there any other ways to get value from other frame with input type = submit?
Or should I change the input type?

Thank you!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Entering "e" as numeric input in Textbook ColinC BOOK: Excel VBA 24-Hour Trainer 2nd edition 9 October 5th, 2016 08:13 PM
class="x" to input control in Sell page doen't work? torr6420 BOOK: Beginning ASP.NET Web Pages with WebMatrix 2 December 5th, 2011 04:50 AM
"type" attribute in <script> tag Latinsteps BOOK: Beginning JavaScript 4th Edition 2 September 6th, 2011 01:29 AM
<input type="Checkbox" question??? RinoDM HTML Code Clinic 1 October 26th, 2009 06:00 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM



All times are GMT -4. The time now is 09:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.