<%@page pageEncoding="ISO-8859-1"%>
<?xml version="1.0" encoding="ISO-8859-1" ?>
Segue abaixo o código da duas páginas JSP:
PÁGINA DE ENVIO / RECEBIMENTO<%@ page contentType="text/html"%>
<%@ page pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Envio</title>
<script type="text/javascript">
<!--
var xmlhttp = null;
function pegaConteudo() {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined' ) {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false ;
}
}
if (xmlhttp) {
var pConteudo= document.form1.txtConteudo.value;
xmlhttp.onreadystatechange = processadorMudancaEstado;
xmlhttp.open("POST", "retorno.jsp?parametro="+pConteudo);
xmlhttp.send(null);
}
}
function processadorMudancaEstado () {
if ( xmlhttp.readyState == 4) { // Completo
if ( xmlhttp.status == 200) { // resposta do servidor OK
document.getElementById("div_conteudo").innerHTML = xmlhttp.responseText;
} else {
alert( "Problema: " + xmlhttp.statusText );
}
}
}
-->
</script>
</head>
<body>
<form name="form1" id="form1">
<div id="div_conteudo">" Aqui o parametro será retornado "</div>
<input type="text" name="txtConteudo" id="txtConteudo">
<input type="button" value="Enviar parametro" name="carregador" id="carregador" title="Carregador" onclick="pegaConteudo();">
</form>
</body>
</html>
<% @page contentType="text/html"%>
<% @page pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Retorno</title>
</head>
<body>
<%=request.getParameter("parametro")%>
</body>
</html>
