我在Eclipse中爲一個現有的appengine網站搞了一些java源代碼。我想要獲得現有網頁中的一個,以顯示Google地球插件小程序。如何在java servlet中插入一段html代碼
我有這個在html文件中工作的小片段,但我不知道如何讓servlet將它放入它生成的html中。
我不是一個真正的編碼器,所以我需要一些關於如何讓java來完成這項工作的非常有用的指示。
<script src="http://www.gmodules.com/ig/ifr?url=http://code.google.com/apis/kml/embed/tourgadget.xml&up_kml_url=https%3A%2F%2Fwebfiles.colorado.edu%2Fwww%2FLSF%2520DB%2520Placemarks5.kmz&up_tour_index=1&up_tour_autoplay=1&up_show_navcontrols=1&up_show_buildings=1&up_show_terrain=1&up_show_roads=0&up_show_borders=1&up_sphere=earth&synd=open&w=700&h=600&title=Embedded+Tour+Player&border=http%3A%2F%2Fwww.gmodules.com%2Fig%2Fimages%2F&output=js"></script>
===
protected void beginBasicHtmlResponse(String pageName, String headContent, HttpServletResponse resp,
HttpServletRequest req, boolean displayLinks) throws IOException {
resp.addHeader(HOST_HEADER, getServerURL(req));
resp.setContentType(ServletConsts.RESP_TYPE_HTML);
resp.setCharacterEncoding(ServletConsts.ENCODE_SCHEME);
PrintWriter out = resp.getWriter();
out.write(HtmlConsts.HTML_OPEN);
out.write("<link rel=\"icon\" type=\"image/png\" href=\"/odk_color.png\">");
out.write(HtmlUtil.wrapWithHtmlTags(HtmlConsts.HEAD, headContent + HtmlUtil.wrapWithHtmlTags(
HtmlConsts.TITLE, BasicConsts.APPLICATION_NAME)));
out.write(HtmlConsts.BODY_OPEN);
out.write(HtmlUtil.wrapWithHtmlTags(HtmlConsts.H2, "<FONT COLOR=330066 size=0><img src='/odk_color.png'/>" + HtmlConsts.SPACE + BasicConsts.APPLICATION_NAME) + "</FONT>");
if (displayLinks) {
UserService userService = UserServiceFactory.getUserService();
out.write(generateNavigationInfo());
out.write(HtmlConsts.TAB + HtmlConsts.TAB);
out.write(HtmlUtil.createHref(userService.createLogoutURL("/"), "Log Out from "
+ userService.getCurrentUser().getNickname()));
out.write(HtmlConsts.TAB + "<FONT SIZE=1>" + ServletConsts.VERSION + "</FONT>");
}
out.write(HtmlConsts.LINE_BREAK + HtmlConsts.LINE_BREAK);
out.write(HtmlUtil.wrapWithHtmlTags(HtmlConsts.H1, pageName));
}
您已經確定了代碼。OUPUTS現有的HTML位?如果是這樣,你可以在這裏發佈? – Jaydee 2011-03-23 13:37:24