Re: Bizarre sporadic problem with streaming a stylesheet.
On Tue, 21 Sep 2010, Rahul Mohan wrote: Did you take a look at this request through Firebug? It might show some useful info. I haven't, but I'm not sure where this would pin it down. For example, if I use curl to pull the stylesheet rapid fire: curl http://localhost:8080/congo/public/getConfiguredStylesheet.action it works every single time. The funny bit is that I don't think it's the server. The webpage is just the JSP plus the link rel line. Oddly, the problem happens in Firefox and in Struts. :-/ Also, is the content type proper (text/css) in the request header? I can't see you setting it anywhere. I didn't have it ther,e but adding it like this: resp.setContentType(text/css); didn't make any difference. -d - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Bizarre sporadic problem with streaming a stylesheet.
On Tue, 21 Sep 2010, Dale Newfield wrote: On 9/21/10 12:36 AM, Dave Belfer-Shevett wrote: LINK REL=StyleSheet href=getConfiguredStylesheet.action type=text/css It shouldn't matter, but the browser might be deciding something wonky based on the fact that that url doesn't end .css...you could either add css as an action extension or maybe use urlrewrite to make a .css url actually result in your .action request. Tried it both ways -one as an action class, one as a css. The headers didnt' vary enormously (or relevantly). public void getConfiguredStylesheet() throws IOException, Exception { Shouldn't all action methods return String? What's the action mapping associated with this? -should-, but all this class is doing is writing to the HttpServletResponse object. resp.getWriter().write(sb.toString()); resp.getWriter().flush(); resp.getWriter().close(); The appropriate return value for actions that generate their own output is null. This is rarely the best solution, though, as there's more to the http protocol than the content of the response. You're returning no header information. That's not the case actually - the http headers are there (curl -i shows them). curl http://localhost:8080/congo/public/getConfiguredStylesheet.action try curl -i to see the header info. Compare that output to a curl -i request for a .css file delivered by your web app through more conventional methods. resp.setContentType(text/css); I believe that since you're generating the response yourself this has no effect. If you want to return a stream, there is a stream result type that'll help you out: http://struts.apache.org/2.2.1/docs/stream-result.html It's not -really- a stream. I perhaps used the wrong name there. See other comments in this thread (or comments taht'll be there in a few minutes :) -d - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Bizarre sporadic problem with streaming a stylesheet.
On Tue, 21 Sep 2010, Martin Gainty wrote: to ask the unasked question..If Streaming is associated with media types such as audio or video How does one stream a stylesheet? As someone else commented, I'm not actually 'streaming'. What I'm using is a database to source the stylesheet (in the final version, hte stylesheet will be assembled). The short version is the stylesheet is not static - it's being generated programmatically, and being fed back into the HttpServletResponse directly. -d -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: d...@jabber.stonekeep.com \ blog:planet-geek.com '---. d...@homeport.org/ Life is full of misery, loneliness, and \ --- suffering - and it's all over much too | | soon. (Woody Allen) | \__/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Bizarre sporadic problem with streaming a stylesheet. [Solved?]
So this got weird. I tried everything. Rewrote the method, changed the responses, put debugging all over - nada. I could reproduce the problem by rapid-firing ^R at the browser, and the home would render with the stylesheet about half the time. It was interesting seeing it flip back and forth. My JSP's had two stylesheet lines in them, like this: LINK REL=StyleSheet href=getStylesheet.action type=text/css LINK REL=StyleSheet href=getConfiguredStylesheet.action type=text/css The first one would have loaded the 'default' style, with the configured oversion overriding / updating the sheet as necessary. I removed the first one. And it all started working perfectly. I don't know if it's a bug in the first action class (which HAD been working perfectly on it's own until I added the second line), or what - but I'm running now. How. Weird. -d - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Bizarre sporadic problem with streaming a stylesheet.
Help me obi-wan struts-geeks. This one is puzzling me. I need to 'stream' a stylesheet out to the browser. Due to the app, that stylesheet is sort of generated on the fly from the database, so I can't just point the browser at a static file. In the document, I have: head meta http-equiv=Content-Type content=text/html; charset=UTF-8 LINK REL=StyleSheet href=getConfiguredStylesheet.action type=text/css /head Here's the method mapped to this (note this is at the moment reading from a file off the filesystem, not from the db - but even the comment in the StringBuffer doesn't show up) public void getConfiguredStylesheet() throws IOException, Exception { logger.info(Fetching configured stylesheet...); sessionData = ActionContext.getContext().getSession(); // Open up the .css file specified in the event try { InputStream is = sc.getResourceAsStream(/public/web-emphasis.css); logger.debug(inputstream for stylesheet should not be null. It is: + is); BufferedReader br = new BufferedReader(new InputStreamReader(is)); logger.debug(Setting up sb with basic stylesheet info...); StringBuffer sb = new StringBuffer(/* Read via CSSFetcher from web-emphasis.css */\n); String s ; int counter=0; while ((s = br.readLine()) != null) { counter++; sb.append(s + \n); } logger.debug(Stringbuffer counted + counter + lines, and is + sb.length() + bytes long.); is.close(); logger.debug(Writing it to the response...); resp.getWriter().write(sb.toString()); resp.getWriter().flush(); resp.getWriter().close(); } catch (Exception e) { logger.error(e); logger.error(e.getMessage()); e.printStackTrace(); throw e; } } Here's the problem. The stylesheet shows up in the browser - only about 4 times out of 5. Every 3rd, 4th, 5th, sometimes 6th webhit, there's no stylesheet. The log, however, shows that the stylesheet went out - no matter whether it's available in the stylesheet viewer on the browser or not, the log always says: 2010-09-20 23:30:20,743 INFO [CSSFetcher] Fetching configured stylesheet... 2010-09-20 23:30:20,743 DEBUG [CSSFetcher] inputstream for stylesheet should not be null. It is: java.io.bufferedinputstr...@23b35955 2010-09-20 23:30:20,744 DEBUG [CSSFetcher] Setting up sb with basic stylesheet info... 2010-09-20 23:30:20,743 INFO [CSSFetcher] Fetching con-specific stylesheet information... 2010-09-20 23:30:20,744 DEBUG [CSSFetcher] Stringbuffer counted 259 lines, and is 4889 bytes long. 2010-09-20 23:30:20,745 DEBUG [CSSFetcher] Writing it to the response... My guess is there's some weird interraction with timing with how the stylesheet is being loaded and when the browser is expecting it to be completed. I can't for the life of me figure out what it is. The flush() and close() lines in the method were added to attempt to 'finish up' the connection, but they made no difference. Help? -d - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Session variables in s:radio buttons - preselection and formatting?
I have a twofold question. The first is I have a session variable called 'sendto' which contains a string ('registrant','none', or 'everyone'). When the page with the radio buttons is rendered, I want to preselect based on whatever the value in the session hash for 'sendto' is set to. Code: div style=float: right; width: 150px; bNotifications/bhr Send email to:br s:radio list=#{'none':'None','registrant':'This Registrant','everyone':'Everyone on this invoice'} value=#{sendto} name=sendto / /div I woudl have thought the value=#{sendto} would have done that, but it doesn't. I've checked and the session key 'sendto' does have the value 'registrant' in it. Secondly - These render on a straight line, one right after another. I'd like line breaks br between each radio button. Is this possible? Thanks! -dbs - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Simple redirect, OFF-site.
Hey folks, I was just searching the archives (lots of requests for redirects, but not one similar to what I need). I'm implementing a Paypal payment gateway, which requires an HTTP call to get a URL from a remote webservice, then I need to redirect the user to that URL. I have the URL (that part is all coded), now all I need to do is redirect the users browser to http://something.paypal.com/someparameter. In scriptlet mode, I'd just do: % String redirectURL = http://something.paypal.com/someparameterB;; response.sendRedirect(redirectURL); % To do this in the struts-way I'd need to make my action responseaware and feed data into it. I'd rather just do something like String target = http://somewhere.paypal.com/;; return redirect; then in struts.xml result name=redirect type=redirect-action /WEB-INF/jsp/Redirect.jsp/ and have my Redirect.jsp have a ${target} in it How to do this? In short, how do I have a struts action redirect the users browser to an arbitrary (off-site) URL? -dbs -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: d...@jabber.stonekeep.com \ blog:planet-geek.com '---. d...@homeport.org/ 7. Twelve-ounce pound cake. (from 'Top 50 \ --- Oxymorons') | \__/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Simple redirect, OFF-site.
On Mon, 16 Feb 2009, Musachy Barroso wrote: See this page: http://struts.apache.org/2.x/docs/parameters-in-configuration-results.html use redirect, instead of redirectAction for the result type. That did it, thanks. -d -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: d...@jabber.stonekeep.com \ blog:planet-geek.com '---. d...@homeport.org/ I intend to live forever-so far, so good. \ \__/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Tons of Could not find property messages - log4j is not helping?
I saw another thread about this already, and the suggestions were to turn off dev mode (I'm not running devmode), or to filter them out in my logging mechanism. I have log4j.xml in my .war file, and I use it to control logging in all my classes, but I can't find the right magical incantation to turn this one off. Currently I'm using: category name=com.opensymphony.xwork2.util.logging.commons.CommonsLogger priority value=ERROR/ /category but that is doing nothing (i've tried various incantaions on the name line, none have any effect). Help please? -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \ blog:planet-geek.com '---. [EMAIL PROTECTED]/ 25)You can't spit out the car window without \ ---pulling over to the side of the road and| | stopping. (from You might be a yankee | |if...) | \__/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 'include' struts.xml stuff is broken?
On Wed, 16 Jul 2008, Dave Newton wrote: --- On Tue, 7/15/08, Dave Belfer-Shevett [EMAIL PROTECTED] wrote: [...] the documentation page for this, naturally, provides no examples of what the include file should look like. Naturally? Sniping aside: the include documentation [1] states the following: Each included file must be in the same format as struts.xml, including the DOCTYPE. The include files can be placed anywhere on the classpath and should be referred to by that path by the file attribute. To me that implies a well-formed, complete S2 config file. And was completely unmentioned in the document I was looking at: http://struts.apache.org/2.x/docs/can-we-break-up-a-large-strutsxml-file-into-smaller-pieces.html That FAQ should have had a link along the lines of Full documentation for include is [here...]. What neither document mentions is how to configure both the top level struts.xml and the secondary files to avoid duplicating entire interceptor stacks using packages. 1-2 lines referring to other bits of information would have been enormously helpful. I did finally get it working, using an include in struts.xml, and in the included struts.xml, added dtd, a new package definition, and an 'extends=' reference to the parent package. -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \ blog:planet-geek.com '---. [EMAIL PROTECTED]/ Windows98 Err#021 - Error Parsing Error\ ---List; Please Wait For Next Error| \__/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
'include' struts.xml stuff is broken?
This seems like it should work, but I'm getting all sorts of hassles, and the documentation page for this, naturally, provides no examples of what the include file should look like. My struts.xml has... !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.0.dtd; struts include file=struts-editevent.xml package name=CONGO extends=struts-default interceptors [blah blah blah] /interceptors (more actions) /package /struts The 'struts-editevent.xml' has: action name=coconut/viewEditEvent method=load class=com.stonekeep.congo.coconut.EditEvent interceptor-ref name=mystack / result name=success/WEB-INF/jsp/coconut/EditEventForm.jsp/result result name=login type=redirect-actioncoconut/showloginpage/result /action action name=coconut/postEditEvent method=update class=com.stonekeep.congo.coconut.EditEvent interceptor-ref name=mystack / result name=success/WEB-INF/jsp/coconut/Maintenance.jsp/result result name=input/WEB-INF/jsp/coconut/EditEventForm.jsp/result result name=login type=redirect-actioncoconut/showloginpage/result /action A basic block of actions. I'm getting XML validatoin errors up the wazoo because the struts-editevent.xml file isn't well-formed. If I put it in struts blocks, I get you're referencing interceptors that don't exist. If I try and duplicate the entire package, interceptors, and DTD definition into the include file, I get package collisions. My take is the include function does not work as described in the documentation. It should be a linear include, and the resulting document is parsed by SAX, but that doesn't seem to be happening. Can someone give me an example of an included XML file that actually works? Here are links to what I'm seeing: My main struts.xml: http://pastebin.stonekeep.com/4955 My struts-editevent.xml: http://pastebin.stonekeep.com/4956 What happens when I deploy: http://pastebin.stonekeep.com/4957 Note that says no grammar found. Adding the DTD says you need a package name in your struts block - etc etc etc. It never really resolves. Can someone show me an include setup that actually works? -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \ blog:planet-geek.com '---. [EMAIL PROTECTED]/ Windows98 Err#021 - Error Parsing Error\ ---List; Please Wait For Next Error| \__/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Referring to Properties object via OGNL?
On Monday 14 July 2008 00:30:19 Jeromy Evans wrote: Dave Belfer-Shevett wrote: In my JSP, I have: Preferred cid is s:property value=#attr.properties[preferredcid]/br This expression reads evaluate perferredcid, then get the value of #attr.properties[evalresult]. I expect you want. s:property value=#attr.properties['preferredcid']/ so it uses the literal string 'preferredcid' instead of evaluating it. Please let me know if that fixes it. OGNL doesn't provide much useful feedback for cases like these. That fixed it. Is there a chance we can update the 'collections' page in the struts docs to give information like this? Thanks again. -d - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Referring to Properties object via OGNL?
I have a situateion where I'm loading application specific settings via a Properties object on initialization. I'm storing the Properties object up into the ApplicationMap (heck it could be in the SessionMap, I'm easy), but i can't seem to switch JSP behaviour based on information in the Properties map. I'm wondering if this is because Properties isn't exactly a HashMap, so the #attr.mapname.somekey isn't working. If I have a Properties object called 'props' in the SessionMap (or anywhere on the stack actually), I should be able to get to it via #attr - what's the proper syntax? Java-wise, it's Property p = new Properties; String value = p.getProperty(somekey) but naturally I don't want to do this in a scriptlet. Help? -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \ blog:planet-geek.com '---. [EMAIL PROTECTED]/ Things you'll hear if you have a Klingon on \ --- your development team: 3) This code is a| | piece of crap! You have no honor! | \__/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Referring to Properties object via OGNL?
On Sun, 13 Jul 2008, Martin Gainty wrote: access it with % ValueStack stack = getStack(); stack.findValue(#attr.someKey); % http://www.docjar.com/docs/api/java/util/Stack.html where you put the value.. HashSet,HashMap or Property is up to you.. Doesn't this violate the 'scriptlets are bad' concept? -dbs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Referring to Properties object via OGNL?
On Sun, 13 Jul 2008, Gabriel Belingueres wrote: Properties implements the Map interface, so AFAIK, it should work accessing it as a Map. Did you tried #attr.mapname[somekey]? Yes... I have an interceptor that does: applicationMap = invocation.getInvocationContext().getApplication(); applicationMap.put(properties,props); logger.debug(Props loaded: + props.toString()); (when run, this sez: 2008-07-12 23:18:37,828 DEBUG com.stonekeep.congo.interceptors.DBInterceptor:138 - Props loaded: {preferredcid=2008} In my JSP, I have: Preferred cid is s:property value=#attr.properties[preferredcid]/br Which, when rendered: Pddreferred cid is (with nothing after it) The entire interceptor that is loading up the properties file and publishing it into the ApplicationMap is here: http://pastebin.stonekeep.com/4949 I may be missing something painfully obvious, but... help? -d -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \ blog:planet-geek.com '---. [EMAIL PROTECTED]/ Windows98 Err#021 - Error Parsing Error\ ---List; Please Wait For Next Error| \__/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Wildcard mappings with subdirectories / folders?
Hi folks - I'm trying to divide up my struts app into subdirectories (the application has a 'public' interface, and an 'administrative' interface called 'coconut'. Don't ask). I'd like to have 2 wildcard actions that pull JSPs from different subdirectories. (coconut and public) Here's my configs - however, the rules are not matching at all - I have my JSP's in WEB-INF/jsp/coconut/(blah.jsp) and WEB-INF/jsp/public/(blah.jsp). action name=coconut/* interceptor-ref name=mystack / result name=success/WEB-INF/jsp/coconut/{1}.jsp/result result name=login/WEB-INF/jsp/coconut/index.jsp/result /action action name=public/* interceptor-ref name=mystack / result name=success/WEB-INF/jsp/public/{1}.jsp/result result name=login/WEB-INF/jsp/public/index.jsp/result /action No matter what I hit, I get: SEVERE: Could not find action or result There is no Action mapped for action name Welcome. - [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186) Help? -dbs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Wildcard mappings with subdirectories / folders?
On Wed, 18 Jun 2008, Dave Belfer-Shevett wrote: Hi folks - I'm trying to divide up my struts app into subdirectories (the application has a 'public' interface, and an 'administrative' interface called 'coconut'. Don't ask). And here I am answering my own question. A little googling found me this gem: constant name=struts.enable.SlashesInActionNames value=true / And that fixed it. The following action entries work: action name=coconut/* interceptor-ref name=mystack / result name=success/WEB-INF/jsp/coconut/{1}.jsp/result result name=login/WEB-INF/jsp/coconut/index.jsp/result /action action name=public/* interceptor-ref name=mystack / result name=success/WEB-INF/jsp/public/{1}.jsp/result result name=login/WEB-INF/jsp/public/index.jsp/result /action All fixed, thanks! -d -- ---..---. Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \ blog:planet-geek.com '---. [EMAIL PROTECTED]/ Things you'll hear if you have a Klingon on \ --- your development team: 3) This code is a| | piece of crap! You have no honor! | \__/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ApplicationAware not triggering setApplication? Or, how best to reference a Connection pool?
Hi folks - i'm trying to write an interceptor in struts2 that has access to the ApplicationMap in the application context. My understanding is that the webwork API for ApplicationAware means that the interceptor will have it's setApplication(Map applicationData); triggered when the interceptor is run, thereby giving me access to the applicationcontext. Problem is, it isn't :) Here's the relevant parts... public class DBInterceptor extends AbstractInterceptor implements ApplicationAware { ... @Override public void setApplication(Map arg0) { logger.info(Receiving applicationMap...); this.applicationMap = arg0; } That logger is never triggered, 'applicationMap' is always null. My struts.xml is: interceptors interceptor name=dbsetup class=com.stonekeep.congo.interceptors.DBInterceptor / interceptor-stack name=mystack interceptor-ref name=dbsetup / interceptor-ref name=defaultStack / /interceptor-stack /interceptors (The goal here is to store a c3p0 connection pool object in the application context, so that I can get a connection from it on every hit - I assume this is the proper way to do this?) Thanks, any help would be appreciated... -dbs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ApplicationAware not triggering setApplication? Or, how best to reference a Connection pool?
Lukasz Lenart wrote: My understanding is that the webwork API for ApplicationAware means that the interceptor will have it's setApplication(Map applicationData); triggered when the interceptor is run, thereby giving me access to the applicationcontext. ApplicationAware should be used with Actions not with interceptors, to access application just use public String intercept(ActionInvocation invocation) { Map appScope = invocation.getInvocationContext().getApplication(); } That's done it, thank you very much. I was really stymied. -dbs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Noob question(s). Interceptor breaking forms, and Connection handling?
Hi folks, I have two questions, and I apologize for the n00b approach. I'm just teaching myself struts2, coming from a PHP background (but I've done plenty of JEE and Java Swing programming, so the language isn't completely alien :) Question 1... I have a Logon form that works fine without an interceptor, but as soon as I add one, my getUsername() and other methods fail (the username is null). Struts.xml: http://pastebin.stonekeep.com/1893 DBInterceptor: http://pastebin.stonekeep.com/1894 Logon.java: http://pastebin.stonekeep.com/1895 If I uncomment the interceptor line in my struts.xml file, the Logon form validator fails. Line 29 shows 'null' in Logon.java. If i leave it commented out, it works fine. Question 2... In Logon.java, I'm using the execute() method to set up my JDBC connection (as pulled from my JBoss container datasource), setting up the Connection, and making the call. Wouldn't it make more sense to do that in an interceptor around every class, and do something like ic = new InitialContext(); dataSource = (DataSource)ic.lookup(java:JQuoDEV); c = dataSource.getConnection(); Logon action = (Logon)invocation.getAction(); action.connection = c; return invocation.invoke() ; I tried doing this, and saw the connection start up, but the Action class kept having the connection as 'null'. I think I'm either misunderstanding how the interceptor / action sequence works, or doing something blatantly stupid. Help? -dbs -- Dave Belfer-Shevet Stonekeep Consulting, Inc http://www.stonekeep.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]