Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-22-2008, 04:52 PM
Member
 
Join Date: Aug 2008
Posts: 1
rcv007 is on a distinguished road
JSP + Struts + XML + response.setHeader()
Hi dear,

I have an app that generate with Struts/ Actions Class a XML file.
For example:

Code:
package br.com.accessconsult.struts.action; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import br.com.accessconsult.jdbc.dao.LivrosDAO; import br.com.accessconsult.jdbc.modelo.Livros; public class livrosJSP extends Action { @Override public ActionForward execute(ActionMapping map, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String pesq = request.getParameter("pesq"); //System.out.println(pesq); Long isbn = null; //response.setHeader(arg0, arg1); if (!pesq.equals("")) isbn = Long.parseLong(pesq); Livros l = new Livros(); l.setIsbn(isbn); LivrosDAO dao = new LivrosDAO(); List <Livros> livros = dao.getLista(l); String xml = "<livros>\n"; for(int index = 0;index<livros.size();index++){//while (!livros.isEmpty()) { Livros livro = livros.get(index); xml += "<livro>\n"; xml += "<isbn>" + livro.getIsbn() + "</isbn>\n"; xml += "<titulo>" + livro.getTitulo() + "</titulo>\n"; xml += "<edicao>" + livro.getEdicao_num() + "</edicao>\n"; xml += "<publicacao>" + livro.getAno_publicacao() + "</publicacao>\n"; xml += "</livro>\n"; } xml += "</livros>\n"; request.setAttribute("xml", xml); return map.findForward("OK"); } }
and I create a JSP file that display the content:

Code:
<?xml version="1.0" encoding="iso-8859-1"?> <%@ page contentType="text/xml"%> ${xml}
however dear, how do I do to configure and work the function on my Struts Action Class:
Code:
response.setHeader()
I made this:

Code:
package br.com.accessconsult.struts.action; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import br.com.accessconsult.jdbc.dao.LivrosDAO; import br.com.accessconsult.jdbc.modelo.Livros; public class autoresJSP extends Action { @Override public ActionForward execute(ActionMapping map, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { response.setHeader("Cache-Control", "no-cache");//Http 1.1 response.setHeader("Pragma","no-cache");//Http 1.0 response.setDateHeader("Expires", -1); String xml = ""; request.setAttribute("xml", xml); return map.findForward("OK"); } }
to test, and the JSP dont found the headers configuration on my Struts Class.

Dear, how can I do to JSP run correctly receivering the headers configs by Struts Class?

Thanks in advance.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
response.sendRedirect(url) mutuah Advanced Java 2 08-07-2007 03:56 PM
help with response.sendRedirect method katie JavaServer Pages (JSP) and JSTL 1 08-07-2007 04:22 AM
response.sendRedirect problem christina JavaServer Pages (JSP) and JSTL 2 08-03-2007 07:23 PM
Velocity / XML response sabatier XML 0 07-24-2007 03:13 PM
response.setContentType bbq Java Servlet 1 06-28-2007 08:04 AM


All times are GMT +3. The time now is 05:33 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org