I have a textbox input field on my index.jsp
inside form tag page. When I insert the character †
in my textbox, then after hitting submit button, it takes me to its corresponding servlet
. From servlet I get the value of text box using request.getParameter()
. And then show that value as response from servlet on page. But on servlet response it is showing me a junk value : â€
whereas I wanted the same character (†
) as output.
files:
index.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<html>
<body>
<form action="hello.do" method="post">
<input type="text" name="t1"/><br>
<input type="submit"/>
</form>
</body>
</html>
servlet:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String s=request.getParameter("t1");
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println(s);
System.out.println("inside servlet: "+s);
}