<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form method="post" action="viewData.jsp">
<input type="text" name="firstname"><input type="text" name="lastname"><input type="submit">
</form>
</body>
</html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="c" class="sourcef.StringAdd" />
<%
String a = request.getParameter("firstname");
String b = request.getParameter("lastname");
String sname = c.sadd(a,b);
out.print(sname);
%>
</body>
</html>
package sourcef;
public class StringAdd {
public String sadd(String fname,String lname)
{
return(fname+ " "+lname);
}
}