3
I’m writing a JSP page that uses Japanese characters and I’m using the get method, but when I switch to the post method it doesn’t work. I’ve tried to use charset = Shift_jis, but nothing!!
Page JSP:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset = UTF-8">
<title>本</title>
</head>
<body>
<form action="SubmitNameServlet" method="get">
<label for "name">名前</label>
<input type="text" name="nome" id="nome"/>
<br/>
<input type="submit" value="Send Name"/>
</form>
</body>
</html>
Class of the Servlet:
package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SubmitNameServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
doPost(request, response);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String name = req.getParameter("nome");
resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
out.println("<!DOCTYPE html>");
out.println("<html><head><title>日本語</title></head>");
out.println("<body>");
out.println("<h1>始めまして " + name + " </h1>");
out.println("</body>");
out.println("</html>");
}
}
Edit the question and post what you have already done.
– Marconi
The question is much improved.
– Marconi