pessoal, tenho duas paginas .JSP
quero capturar o atributo digitado (input) nesta:
<%@page import="org.apache.catalina.core.ApplicationContext"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<h1>Import/Param</h1>
<form method="get" action="<%=request.getContextPath() %>/operation">
<input type="text" name="${param.n_input}" />
<input type="submit" value="${param.n_bt}" />
</form>
e imprimir nesta
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<div id="div_dois" style="width: 400px;height: 300px;border: 1px double red ">
<p><%=request.getAttribute("val") %></p>
</div>
usando este servlet (preciso mesmo dele?)
package servlets;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class operation extends HttpServlet {
private static final long serialVersionUID = 1L;
public operation() {
super();
}
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String valor = req.getParameter("name");
HttpSession sessao = req.getSession(true);
sessao.setAttribute("val",valor);
RequestDispatcher dispacher = req.getRequestDispatcher("/index.jsp");
dispacher.forward(req, resp);
}
}
e mostrando o resultado na pagina index
atravez de <c:import>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!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>
</head>
<body>
<div id="principal" style="width: 400px;height: 600px">
<c:import url="Fragment1.jsp">
<c:param name="n_input" value="name" />
<c:param name="n_bt" value="submete" />
</c:import>
<c:import url="Fragment2.jsp" />
</div>
</body>
</html>
por favor,
alguem pode me ajudar
grato desde já