English 中文(简体)
直接提供html的内容
原标题:providing html contents directly to the servlet
  • 时间:2011-08-30 14:46:51
  •  标签:
  • java
  • html
  • gwt

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">"+
                   "<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");

这种方法来自ServletResponse,并继承于。 HttpServletResponse

http://download.oracle.com/javaee/5/api/javax/servlet/ServletResponse.html#getOutputStream%2829”rel=“nofollow”>getOutputStream( 用于书写双元数据。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签