📄 writexml.java
字号:
/** EOS Tag Java File **/
package com.primeton.eos.fbframe.tag;
import org.w3c.dom.*;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import com.primeton.tp.web.driver.webdriver.WebDriver;
import com.primeton.eos.webtag.util.ResponseUtils;
import com.primeton.tp.core.prservice.context.*;
import com.primeton.tp.common.logger.Logger;
import com.primeton.tp.common.xml.XmlUtil;
public class WriteXml extends TagSupport {
private String property;
private String id;
private String scope;
public WriteXml() {
property = null;
id = null;
scope = "request";
}
public String getProperty() {
return property;
}
public void setProperty(String value) {
this.property = value;
}
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
public String getScope()
{
return scope;
}
public void setScope(String s)
{
scope = s;
}
public int doStartTag() throws JspException {
//TODO Add your code here.
Node n = null;
if (scope.equals("request")) {
if (id == null)
id = WebDriver.REQUEST_REQUEST_CONTEXT;
RequestContext requestcontext = (RequestContext)pageContext.getAttribute(id);
if (requestcontext == null)
requestcontext = (RequestContext)pageContext.getRequest().getAttribute(id);
if (requestcontext != null) {
try
{
n = requestcontext.getEntity(property);
}
catch (Exception exception)
{
Logger.error(this, "WriteXmlTag :: getProperty{" + property + "} error");
n = null;
}
}
} else if (scope.equals("session")) {
if (id == null)
id = "sessionContext";
SessionContext sessioncontext = (SessionContext)pageContext.getSession().getAttribute(id);
if (sessioncontext != null) {
try
{
n = sessioncontext.getEntity(property);
}
catch (Exception exception1)
{
Logger.error(this, "WriteXmlTag :: getProperty{" + property + "} error");
n = null;
}
}
} else {
Logger.error(this, "WriteXmlTag :: scope{" + scope + "} not exist");
}
if (n == null || n.getNodeType()== Node.ATTRIBUTE_NODE)
ResponseUtils.write(pageContext, "");
else {
String s = XmlUtil.node2String(n);
if (s.startsWith("<?xml")) {
int p = s.indexOf("?>");
if (p > 0) {
p += 2;
for (;p<s.length(); p++) {
if (s.charAt(p) == '<')
break;
}
ResponseUtils.write(pageContext, s.substring(p));
return 0;
}
}
ResponseUtils.write(pageContext, s);
}
return 0;
}
public int doEndTag() throws JspException {
//TODO Add your code here.
return super.doEndTag();
}
public void release() {
property = null;
id = WebDriver.REQUEST_REQUEST_CONTEXT;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -