I am try to save a Text as Attribute in servlet and forward it to a HTML page.Then need to show it in Html page body. Help me to send the data as response to HTML.then help to show the value in HTML page. In JSP is working fine.but i need to send the response to html page and show it.
Here i am using Request dispatcher for send the request and response to html page.
but i am not clear with how to display it in html.Help me tp solve.
thanks
//NewServlet.java
public class NewServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.setAttribute("Cricket", "Sachin");
RequestDispatcher rd = request.getRequestDispatcher("index.html");
rd.forward(request, response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}
//index.html