Page
1: Sportsget.html
<!DOCTYPE
HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta
http-equiv="Content-Type" content="text/html;
charset=UTF-8">
</head>
<body>
<form
id ="contextParam" action="/html/sportgetservlet"
method="">
<b>Sport:</b>
<select
name="sports" size="1">
<option
value="Cricket">Cricket<option/>
<option
value="Hockey">Hockey<option/>
<option
value="Football">Football<option/>
</select><br><br>
<input
type="submit" value="submit">
</form>
</body>
</html>
Output:
Page
2: Spotsgetservlet.java
import
java.io.*;
import
java.net.*;
import
javax.servlet.*;
import
javax.servlet.http.*;
public
class sportgetservlet extends HttpServlet {
protected void doGet(HttpServletRequest
request, HttpServletResponse response)
throws ServletException, IOException {
String
Sport=request.getParameter("sports");
response.setContentType("text/html");
PrintWriter Pw=response.getWriter();
Pw.println(" Selected sports is
--->");
Pw.println(Sport);
Pw.close();
}
}
Output:
No comments:
Post a Comment