providing html contents directly to the servlet
we are providing html contents directly to the servlet,instead of that html file,but its not geting hit on onmoduleload() in the gwt entrypoint. following is the snippet of my code,
String xml=getHtmlForAuthPage();
resp.getOutputStream().write(xml.getBytes());
public String getHtmlForAuthPage(){
StringBuilder sb = new StringBuilder();
sb.append(
"<html> "+
"<head>" +
"<meta http-equiv=\"content-type\" content=\"text/html; charset=\"UTF-8\">" +
" <title>" +
"Auth test"+
" </title>"+
"<link type=\"text/css\" rel=\"stylesheet\" href=\"auth.css\开发者_StackOverflow中文版">"+
"<script type=\"text/javascript\" language=\"javascript\" src=\"com.ensarm.auth.auth/com.ensarm.auth.auth.nocache.js\">"+
"</script>"+
"<link rel=\"shortcut icon\" href=\"favicon.ico\">" +
"</head>"+
"<body>"+
"<iframe src=\"javascript:''\" id=\"__gwt_historyFrame\" tabIndex='-1' style=\"position:absolute;width:0;height:0;border:0\">"+
"</iframe>"+
"<table align=\"center\" >"+
"<tr align=\"center\" valign=\"top\">"+
"<td align=\"center\" id=\"auth\">"+
"</td>"+
"</tr>"+
"<tr align=\"center\" valign=\"bottom\">"+
"<td align=\"center\" id=\"footer\">"+
"</td>" +
" </tr>" +
" </body>"+
"</html>");
return sb.toString();
}
I think you want to use resp.getWriter().print("your-html-content-here");
This method is from ServletResponse
, and inherited by HttpServletResponse
.
getOutputStream()
is used for writing binary data.
精彩评论