• Post Reply Bookmark Topic Watch Topic
  • New Topic

showing the data in jsp

 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am setting the data in xml in my action is like this:

public String replaceList()
{
log.info("replaceList");
User user = (User) getSession().get("loginDetails");
if (user == null) {
addActionMessage("Not Authorize to view this page.");
return ERROR;
}

WorkOrderDBdao workOrderDBdao = new WorkOrderDBdao();
listSearch=workOrderDBdao.getreplaceList(workorder, user.getCustType());
String temp=this.toXML(listSearch);


servletResponse.setContentType("text/xml");
servletResponse.setHeader("Cache-Control", "no-cache");
PrintWriter pw;
try {
pw = servletResponse.getWriter();
pw.write(temp);
pw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return "replacelist";

public String toXML(List<WorkOrder> list)
{
StringBuffer stringBuffer=new StringBuffer();
stringBuffer.append("<root>");
for (WorkOrder wo : list) {
stringBuffer.append("<list>\n");
stringBuffer.append("<name>\n");
stringBuffer.append(wo.getCandidate_name()+"\n");
stringBuffer.append("</name>\n");
stringBuffer.append("<proname>\n");
stringBuffer.append(wo.getProjectName()+"\n");
stringBuffer.append("</proname>");
stringBuffer.append("</list>\n");
}

But how can now i display xml data in jsp.

Please tell me.

 
Paul Clapham
Sheriff
Posts: 21889
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the thing to do would be to put that string into a session variable, then use the <c:out> JSTL tag to display the XML in the response. But that's a question about JSP, isn't it? We do actually have a JSP forum here, so why don't I just move the question over there?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!