RNillll RNillll - 1 month ago 4
Java Question

Forward data to JSP page

I am trying to forward 3 values to another JSP page where they will be multiplied and the result will be displayed. Clicking on the submit button doesnt do anything.

JSP Page 1:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Simple Interest Page</title>
<body bgcolor="pink">
<%@ include file="header.jsp" %>
<form name="calcsimple.jsp" method="post">
<h5 style="font-size: 150%">Simple Interest Page</h5>

Principal Amount:<input type="number" name="pr" value=""/>
Interest Rate:<input type="number" name="ir" value=""/>
Time Period:<input type="number" name="tp" value=""/>
<input type="submit" name="submit" value="submit"/>


<%@include file="footer.jsp" %>


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

int result=0;
String s1=request.getParameter("pr");
String s2=request.getParameter("ir");
String s3=request.getParameter("tp");




result=<%= result+""%>


The problem is probably because you didn't put the "action" of the form, putting the "name" instead. It should be action='calcsimple.jsp'

Hope it helps you! :)