Reputation: 332
How can i pass the value=x in to the servlet from the JSP? I searched for many related questions but could not get my answer. Here x is a variable.
<html>
<body>
<%@ page import="java.lang.*"%>
<%!int x,y; %>
<% String a,b;
a=request.getParameter("jobs");
b=request.getParameter("process");
x=0;
y=0;
try
{
x=Integer.parseInt(a);
y=Integer.parseInt(b);
}
catch(Exception e)
{ }
out.println("You selected - <br>");
out.println("Jobs - "+x+"<br>");
out.println("Process - "+y);
String path="table?input=x";
%>
<jsp:include page="table" >
<jsp:param name="input" value=x/>
</jsp:include>
</body>
</html>
Upvotes: 2
Views: 878
Reputation: 2604
Since the variable x is within a scriptlet, you need to use <%= %>
<jsp:include page="table" >
<jsp:param name="input" value="<%=x%>"/>
</jsp:include>
Upvotes: 5