Re: closing the browser after streaming a pdf file
Hi, You could make the pdf file as downloadable instead of trying to open the pdf inside web browser ,Following code will make the pdf download Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); document.open(); document.add(new Phrase(Some dummy text goes here,font)); document.close(); // setting some response headers response.setHeader(Expires, 0); response.setHeader(Cache-Control, must-revalidate, post-check=0, pre-check=0); response.setHeader(Pragma, public); // setting the content type response.setContentType(application/pdf); response.addHeader(Content-disposition, attachment;filename=\GCQuotes.pdf\); // the contentlength is needed for MSIE!!! response.setContentLength(baos.size()); // write ByteArrayOutputStream to the ServletOutputStream ServletOutputStream outs = response.getOutputStream(); outs.write(baos.toByteArray()) ; outs.flush() ; outs.close() ; The above examples uses a third party PDF wrtier API 'itext' - Original Message - From: Rivka Shisman [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Monday, January 02, 2006 11:24 AM Subject: RE: closing the browser after streaming a pdf file Hi Tamas and thanks for trying, What I want to do is to create a pdf report in memory and stream it from my Action to Acrobat. The problem is that first I.E. opens and then Acrobat is opened. But now I have an empty I.E window that I want to close (don't want the user to do it each time). Thanks Rivka -Original Message- From: Tamas Szabo [mailto:[EMAIL PROTECTED] Sent: Thursday, December 29, 2005 6:10 PM To: Struts Users Mailing List Subject: Re: closing the browser after streaming a pdf file Hi On 12/29/05, Rivka Shisman [EMAIL PROTECTED] wrote: Hi Tamas In my jsp I do: html:form action=/CreateMsvItemReports target=_new focus=item_no I want to save the original jsp page - that's why I use target=_new. When I remove the ' target=_new ' I still get an empty jsp page - so still it does not solve my original problem! I don't know what do you wnat to do exactly. But you probably get that empty browser because the Acrobat Reader plugin is set up so that it opens in a new window instead of opening in a browser. You can change this option in the Preferences of Acrobat Reader. Does this solve your problem? The only problem is that if it's an Internet application(usable by anyone) you can't control how the users will configure their Acrobat Reader plugins. Thanks Rivka Tamas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.14.10/218 - Release Date: 1/2/2006 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: So boring issues about character encoding in action ......
Hi, In the struts action you are setting character encoding on 'request' object req ,it however needs to be on 'response' ie res. Deepesh. public class TestAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception { req.setCharacterEncoding(UTF-8); // this should be res.setCharacterEncoding(UTF-8); String description = req.getParameter(description); description = (description == null?:description.trim()); try{ ItemDAO itemDao = ItemDAO.getInstance(); Item item = new Item(); - Original Message - From: Tony Lu [EMAIL PROTECTED] To: user@struts.apache.org Sent: Tuesday, October 18, 2005 11:14 AM Subject: So boring issues about character encoding in action .. I need to create an internationalized Web application by struts,mysql and hibernate. Each component Character Encoding is utf8. It runs well when I run a pure servlet to save 'Chinese Character' to database and load it from database. But when I implement it with struts action, the application can not save Chinese correctly. I really don't know why struts action can not work well. I am sure there is no difference between them. Is there anywhere to set character encoding for action? Please help! --Pure Servlet ( It runs well) - public class UtfTest extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding(UTF-8); String description = request.getParameter(description); description = (description == null?:description.trim()); try{ ItemDAO itemDao = ItemDAO.getInstance(); Item item = new Item(); item.setDescription(description); itemDao.save(item); }catch(Exception e){ e.printStackTrace(); } response.sendRedirect(test.jsp); } } --Action for struts public class TestAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception { req.setCharacterEncoding(UTF-8); String description = req.getParameter(description); description = (description == null?:description.trim()); try{ ItemDAO itemDao = ItemDAO.getInstance(); Item item = new Item(); item.setDescription(description); itemDao.save(item); // Determine which action forward should be returned return mapping.findForward(success); }catch(Exception e){ } } } No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.12.2/139 - Release Date: 10/17/2005 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Null Pointer exception when using struts html tag library injspfile
Try creating a new context with the blank struts application,which you said is working fine, and run the jsp there. Something seems to be missing or not properly configured ,I had a similar problem last year when I accidently mixed the config files of version 1.1 and 1.2 Deepesh Nandal. - Original Message - From: Archana Soni [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Friday, September 23, 2005 9:56 AM Subject: RE: Null Pointer exception when using struts html tag library injspfile MC, Actually, the jsp page is referring a page within my application. For testing purpose, I tried with an absolute URL and I sent U that changed jsp. Anyways, I noted that anything between the html tags is not affecting b'coz even after removing the complete body and just leaving (%@ taglib) with an empty body, I am still getting the NullPOinterException. So I guess there is something wrong happening when jsp page is invoked thru the struts framework and that too only when html taglibrary is used. -Archana -Original Message- From: Murray Collingwood [mailto:[EMAIL PROTECTED] Sent: Thursday, September 22, 2005 6:11 PM To: Struts Users Mailing List Subject: RE: Null Pointer exception when using struts html tag library in jsp file Hi Archana Try changing your html:link page to href. ie From: html:link page=http://yahoo.com;Yahoo /html:link to html:link href=http://yahoo.com;Yahoo /html:link From what I gather the 'page' parameters refers to a page within your application. You should use the 'href' parameter to refer to a URI. I've never found any good documentation on the use of various taglib parameters, maybe somebody else on this list could point us in the right direction. PS If you leave the taglib statement in and take out the html:link commands do you still get the NullPointer error? Also, because these URIs are external to the application there is nothing to stop you using a simple html anchor a href=...link/a. The use of the html taglib is only really necessary when referring to elements within your application. Kind regards mc On 22 Sep 2005 at 10:14, Archana Soni wrote: This is my Welcome.jsp file content %@ taglib uri=/tags/struts-html prefix=html % html:html locale=true table align=center cellspacing=2cellpadding=5 border=0 trth Welcome /th/tr /table table align=center cellspacing=2cellpadding=5 border=0 bgcolor=#cbe3ed tr tdbfont face=verdana size=2 html:link page=http://yahoo.com;Yahoo /html:link /font/b/td tdbfont face=verdana size=2 html:link page=http://rediff.com;Rediff/html:link /font/b/td /tr /table /html:html The application is working fine with just omitting the first line of the jsp ( %@ taglib ...). But as soon as I add it, it gives the NullPointerexception -Original Message- From: Murray Collingwood [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 21, 2005 5:14 PM To: Struts Users Mailing List Subject: RE: Null Pointer exception when using struts html tag library in jsp file Can you post your jsp form? On 21 Sep 2005 at 17:12, Archana Soni wrote: Global-forwards are not necessary to be defined. It will work even without it. And the URL pattern can be anything (even other than *.do). Important is that it should be mapped with some servlet name. So I guess changing these will not have any impact. Still I did the correction you suggested. And I am still getting same error. -Original Message- From: Murray Collingwood [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 21, 2005 4:21 PM To: Struts Users Mailing List Subject: RE: Null Pointer exception when using struts html tag library in jsp file struts-config.xml Global-forwards are the application entry points. You don't have any defined. Mine look like this: global-forwards forward name=Home path=/Home.do / forward name=Setup path=/Setup.do / /global-forwards web.xml Your servlet mapping is weird, normally you would specify something like: servlet-mapping servlet-nameaction/servlet-name url-pattern*.do/url-pattern /servlet-mapping Maybe, I'm still thinking in Struts 1.2.7 (having not used 1.1). Have you looked at some example 1.1 applications? I started with one from JohnTopley, it's a good starting point for getting something running and then you can grow from there. Try this: http://www.sitepoint.com/article/struts-first-steps Kind regards mc On 21 Sep 2005 at 15:06, Archana Soni wrote: I am attaching my web.xml and struts-config.xml files -Original Message- From: Murugesan, Kathiresan (Cognizant) [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 21, 2005 12:37 PM To: Struts Users Mailing List Subject: RE: Null Pointer exception when using struts html tag library in jsp file This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may
Problem with Tiles
Hi There, I am stuck at one place while working with tiles, please help. I have my tiles-defs.xml as this: tiles-definitions definition name=.mainLayout path=/WEB-INF/tiles/layout.jsp put name=title value=Welcome to Net Model/ put name=pageheading value=/ put name=header value=/WEB-INF/tiles/header.jsp/ put name=sider value=/WEB-INF/tiles/sider.jsp/ put name=body value=/ put name=footer value=/WEB-INF/tiles/footer.jsp/ /definition definition name=index.page extends=.mainLayout put name=pageheading value=Login / put name=body value=/WEB-INF/tiles/user-login.jsp type=page/ /definition /tiles-definitions AND /WEB-INF/tiles/layout.jsp as this: %@ taglib uri=/WEB-INF/struts-tiles.tld prefix=tiles % %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % html:html head titletiles:getAsString name=title//title META http-equiv=Content-Type content=text/html; charset=UTF-8 LINK href=style.css type=text/css rel=stylesheet /head body tiles:insert attribute=header /br tiles:insert attribute=sider /br tiles:insert attribute=body /br tiles:insert attribute=footer / /body /html:html Now, I need to print the variable 'pageheading'( defined in definition '.mainLayout') in /WEB-INF/tiles/header.jsp . I cannot use tiles:getAsString name=pageheading/ inside /WEB-INF/tiles/header.jsp as pageheading is valid in /WEB-INF/tiles/layout.jsp only . So how do I pass pageheading from index.page to header.jsp through .mainLayout ... Please help . Many Thanks, Deepesh Nandal.
Using Tiles tag inside a tile tag
Hi All, The following code doesnt work : tiles:insert definition=header.page tiles:put name=page-heading value=tiles:getAsString name=heading/ / /tiles:insert because the 'value' attribute contains an tiles tag instead of a static value, Please suggest a solution for this Thanks, Deepesh.
Re: Using Tiles tag inside a tile tag
Thanks Ron, that worked perfect :) - Original Message - From: Holshausen, Ron [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, September 14, 2005 5:30 PM Subject: RE: Using Tiles tag inside a tile tag Hi Deepesh, Try this, it worked for me: tiles:insert definition=header.page tiles:put name=page-headingtiles:getAsString name=heading//tiles:put /tiles:insert -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 14 September 2005 14:15 To: Struts Users Mailing List Subject: Using Tiles tag inside a tile tag Hi All, The following code doesnt work : tiles:insert definition=header.page tiles:put name=page-heading value=tiles:getAsString name=heading/ / /tiles:insert because the 'value' attribute contains an tiles tag instead of a static value, Please suggest a solution for this Thanks, Deepesh. E-Mail Disclaimer Aus Rechts- und Sicherheitsgruenden ist die in dieser E-Mail gegebene Information nicht rechtsverbindlich. Eine rechtsverbindliche Bestaetigung reichen wir Ihnen gerne auf Anforderung in schriftlicher Form nach. Beachten Sie bitte, dass jede Form der unautorisierten Nutzung, Veroeffentlichung, Vervielfaeltigung oder Weitergabe des Inhalts dieser E-Mail nicht gestattet ist. Diese Nachricht ist ausschliesslich fuer den bezeichneten Adressaten oder dessen Vertreter bestimmt. Sollten Sie nicht der vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein, so bitten wir Sie, sich mit dem Absender der E-Mail in Verbindung zu setzen. For legal and security reasons the information provided in this e-mail is not legally binding. Upon request we would be pleased to provide you with a legally binding confirmation in written form. Any form of unauthorised use, publication, reproduction, copying or disclosure of the content of this e-mail is not permitted. This message is exclusively for the person addressed or their representative. If you are not the intended recipient of this message and its contents, please notify the sender immediately. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.24/101 - Release Date: 9/13/2005 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Generate ActionMessage object without referring to the resource file
Hi There, I need to generate an ActionMessage object without referring to the resource file, as the message is received from a different server on the fly. Following code works fine if i have Login.invalid defined in the resource property file. ActionMessage message = new ActionMessage(Login.invalid); But I need it so that the message could be a Java String object ,the Following code DOESN'T work : String message = I am a message ; ActionMessage message = new ActionMessage(message); Please Help, Many Thanks, Deepesh.