Issue
I'm new in using JSP and I need to get a value from a textbox by upon clicking a button. I am using Java Netbeans with the server apache tomcat. This is how it works...
The textbox is enclosed in an HTML tag <table>
once the user inputs a value, he clicks the button then a message box will appear with the value he entered.
I am not familiar with JSP and it gives me a hard time.
Solution
My answer is quite familiar with the first answer.
mainPage.jsp
<html>
<head>
<title>Your Title Here</title>
</head>
<body>
<form action="sample.jsp" method="POST">
<input type="text" id="firstname" name="firstname" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
sample.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%
String firstname = request.getParameter("firstname");
/*
* Some code here
*/
%>
I'm also using apache tomcat.
You have to configure your web.xml as said in the first answer.
Hope that helps.
Answered By - sailhenz