Невозможно отправить целое число из сервлета в JSP.
@WebServlet("/MyServlet")
public class MyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public MyServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Method Get in MyServlet");
int Gconta = Integer.parseInt(request.getParameter("Gcont"));
Gconta = Gconta + 1;
System.out.println(Gconta);
HttpSession session = request.getSession();
session.setAttribute("NGconta", Gconta);
response.sendRedirect("cabecalhost.jsp");
response.getWriter().append("Served at: ").append(request.getContextPath());
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}
Страница JSP
<body>
<h3>O Resultado NGconta:</h3>
<%String Getnumbx = request.getParameter("NGconta"); %>
<%= Getnumbx %>
<%String Getnumb = (String) request.getAttribute("NGconta");%>
<% out.println("Your Result is "+ Getnumb); %>
&{NGconta};
</body>