Re: [OT] was Re: Advice for Struts expert ...
Ted Husted wrote: How about [FRIDAY] You might be a Dogbert if ... ... you are inspired by Internet trolls. :) * Gentle Definition - http://www.askdavetaylor.com/whats_a_troll_and_a_zombie.html * Definitive Definition - http://en.wikipedia.org/wiki/Internet_trolls * A shorter, slightly less definitive definition - http://uncyclopedia.org/wiki/Trolls -Ted. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OT: OutOfMemory
What is textFormat? It isn't a StringBuilder is it? textFormat.append(subText); Eric Plante wrote: for (Integer posLetter: positions){ String subText = fullText.substring(start, posLetter); textFormat.append(subText); subText = null; //not required start = posLetter + 1; } with fullText = 5M and textFormat that's even bigger it crashes. An friend tried with a 15M file using Lingo language and it worked without problems and I bet .NET would have no problem either but I'll know tomorrow. Sorry to hear that. Would you please show some source code relative to the problem? Well, 5000 loops of substring with a big string is terrible. 2005/11/29, Eric Plante <[EMAIL PROTECTED]>: It wasn't there but I added it and whatever I used -Xmx or -XX, it didn't work. I wrote 100m for the -XX... I also checked again where I could optimized and where I could find memory leakage. Reducing the number of string meant using StringBuilder's insertthe slowness of that command makes it not an option. I couldn't find any memory leakage. Where the program systematicaly crash is a loop where I do a substring of the big string everytime(about 5000 loops).I then fill a StringBuilder which will eventualy be bigger than the main string. That's the fastest way I can do what need to be done and it needs to be fast. I'm starting to loose faith in Java...I'll ask a friend that isa.NETspecialist to see if.NET has that problem too...a problem Java shouldn't have... --- I found in my catalina.bat: set JAVA_OPTS= Instead of that, use: set JAVA_OPTS=-XX:MaxPermSize=10m -Xmx512m seems only increase max size of heap rather than perm division. 2005/11/29, Eric Plante <[EMAIL PROTECTED]>: I found the required catalina files and I see 4 lines with the JAVA_OPTS variable. I tried replacing JAVA_OPTS and then %JAVA_OPTS% by -Xmx512m in the catalina.bat file but I still get the error message, what am I suppose to do in that file? - Original Message - From: "netsql" <[EMAIL PROTECTED]> To: Sent: Sunday, November 27, 2005 10:09 PM Subject: Re: OT: OutOfMemory http://tomcat.apache.org/faq/memory.html#adjust Eric Plante wrote: I'm on windows XP and the only catalina files that might serve for configuration are Catalina.properties and catalina.policy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: i18n Issue for Chinese Locale.
Everything looks good. UTF-8 is fine for Chinese. You are getting 9 bytes as a result, which is what you should get for UTF-8 encoding, which is good. But it seems the browser isn't reading it as UTF-8 and just displaying the bytes instead under the default ISO encoding. Try adding this If that doesn't work, can you post the html that is generated. Balasubramaniam, Sezhiyan wrote: Hi, We use STRUTS 1.0.2 in one of our extranet application and we need to support CHINESE locale as part of the scope. I used the following steps as Laurie pointed out in the earlier mail, but somehow the character set is getting corrupted and we are not getting the right result. Can Laurie, Frank or someone else can point me, where the problem could be? Thanks in advance, Bala Created dummy.properties in dreamweaver(UTF-8 supported) as bala1=亲爱的 bala2=非常高兴的通知您被升职为 Ran native2ascii dummy.properties ApplicationResources_zh.properties and the output is, bala1=\u00e4\u00ba\u00b2\u00e7\u02c6\u00b1\u00e7\u0161\u201e bala2=\u00e9\ufffd\u017e\u00e5\u00b8\u00b8\u00e9\u00ab\u02dc\u00e5\u2026\u00b4\u00e7\u0161\u201e\u00e9\u20ac\u0161\u00e7\u0178\u00a5\u00e6\u201a\u00a8\u00e8\u00a2\u00ab\u00e5\ufffd\u2021\u00e8\ufffd\u0152\u00e4\u00b8\u00ba JSP is, <%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ page import="java.util.*" %> <%@ page import="java.text.*" %> <%@ page import="org.apache.struts.action.*" %> <% Locale locale=new Locale("zh", "CN"); session.setAttribute("org.apache.struts.action.LOCALE",locale); %> Result is, 亲爱的 -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: new website look
Seems to happen in FF when I have the sidebar open. Closing the sidebar and it looks fine, open it and the image overlap appears. David G. Friedman wrote: +1 I also found the image problem on Opera 8.01 build 7642 and I can confirm the problem on FF 1.0.7. It's funny to see the resize work normally in my IE6 but not in those other two. Regards, David -Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Graham Reeds Sent: Monday, October 24, 2005 2:50 AM To: user@struts.apache.org Subject: Re: new website look Michael Jouravlev wrote: Left column is resizable with some weird width persentage. ApacheCon ad does not resize, and sticks out. Background is not set, too. On 10/22/05, Adam Hardy <[EMAIL PROTECTED]> wrote: Hi All, nice new fresh looking website. Is that the maven-generated one? Can confirm that on FF 1.0.7 but is fine on IE6. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: Submit form with and
I like the tag due to the ability to have markup inside the button, except that it is no use because IE doesn't follow the standard. You can use with fancy html in here like bold for example which makes nice buttons with mark-up and stuff. You can have several of these type="submit" buttons in a form. What you would expect is for only the button that is clicked to submit the form and send it's value, but IE sends the name/value pair of any button element in the form, so you can't tell which button was clicked. Works in FireFox though. Laurie Harper wrote: No, *I* confused us both I think... I was talking about the HTML element, not the element... Seems odd they wouldn't be equivalent, but still! L. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: a little bit OT: Calendar misbehaviour
If timezone if the problem, then use SimpleDateFormat.setTimeZone() and Calendar.setTimeZone() to set the timezones to UTC. That should eliminate the timezone correction and give you the right number. Wojciech Ciesielski wrote: I try to parse some input from HTML form with Java.sql.Timestamp toReturn; SimpleDateFormat dateFormatTime("HH:mm"); Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(0); cal.setTime(dateFormatTime.parse(timeString)); toReturn = new Timestamp(cal.getTimeInMillis()); The point is, that getTimeInMillis() is returning 0 if timeString contains only minutes (like "00:20") while cal.getTime().toString returns properly "Thu Jan 01 00:10:00 CET 1970". Why is it so? How can I initialize that Timestamp with such a string if this approach does not work? I know what is the cause of this problem but still don't know how to work around this... :-( The problem is that in Poland we have GMT+01 time zone. Therefore default time zone here is set to GMT +01. And time "Thu Jan 01 00:10:00 CET 1970" is not translatable to milliseconds because getTimeInMillis() returns time in UCT and it would be 50 minutes before Epoch... Can anybody suggest any way of parsing time string to Timestamp? Is using separate fields for hours and minutes the only solution available? TIA - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: [IMPORTANT] tomcat 5.0.19+ is broken / not useable with struts / your voice needed
:( I wonder if the new java.util.concurrent classes could be used instead of simple HashMap? http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ConcurrentHashMap.html but that would mean total dependence on j2se 1.5 and that would be a problem for supporting j2se 1.4, though a backport is being worked on here http://www.mathcs.emory.edu/dcl/util/backport-util-concurrent/ other reading here: http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html I think that sort of thing would provide a nice solution for speed + reliability. Leon Rosenberg wrote: to whom it may concern There is a serious bug in tomcat 5. To make it short, if you write to or read from session (taglibs included) and have a chance that there is more than one request from same user currently proceeded on the server (and it can be just a web-page refresh, our beloved F5 key) you are f**ked. What happens is that the HashMap where the session attributes are stored got corrupted, and the entry.next in the HashMap points to itself (or start of the list). Next request to the session.getAttribute results in an endless loop, and your server has 100% cpu load. You can read full bug description at: http://issues.apache.org/bugzilla/show_bug.cgi?id=36541 What does it mean for us, struts-users? If we use the session scope: 1. Struts-taglibs aren't thread-safe. 2. Application that are working under tomcat 4.1 or resin, or probably any other servlet container will not work under tomcat 5 (or are not reliable). 3. We must forbid users to have multiple browsers open. 4. We can't handle multiple frames or concurrent requests from same user / session. 5. ... many other examples available. affected versions: 5.0.19+ 5.5.x If you ever had actions hanging around in session.getAttribute()/HashMap.get() for hours and don't know why -> it's your bug. What can you do: Please, click the bug link (http://issues.apache.org/bugzilla/show_bug.cgi?id=36541) and read it ALL carefully. Decide whether you may or may not be affected by this issue. If you are affected by this issue, and most of us are affected, log in and vote for the bug. If you don't have a bugzilla account, but are affected by this bug: setup a bugzilla account and vote. Similar request has been started by Wade Chandler at tomcat-users list. regards Leon P.S. One more thing, could struts-developers team supply a patch for tomcat 5.0.x and 5.5.x for download on the struts homepage? surrounding calls to attributes hashmap with synchronized(attributes){} as it was done in 4.1.x is sufficent. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Upload: strange characters in german filename
Looks like the filename is being sent as utf-8, but being read as Latin1 (can't remember the iso number). Struts uses Commons FileUpload to handle the file uploads. By default it uses org.apache.struts.upload.CommonsMultipartRequestHandler Now Commons FileUpload has a method called setHeaderEncoding (- http://jakarta.apache.org/commons/fileupload/apidocs/org/apache/commons/fileupload/FileUploadBase.html#setHeaderEncoding(java.lang.String) If you can call FileUpload.setHeaderEncoding("utf-8") before the headers are read that should fix the problem. One way to do that is override the default handler with your own one in struts-config.xml eg Then to modify org.apache.struts.upload.CommonsMultipartRequestHandler by creating our my.own.MultiPartClassHandler class. We need to modify the handleRequest() method like so: // Create and configure a DIskFileUpload instance. DiskFileUpload upload = new DiskFileUpload(); upload.setHeaderEncoding("UTF-8"); // Set the maximum size before a FileUploadException will be thrown. upload.setSizeMax((int) getSizeMax(ac)); ... ... Bart Frackiewicz wrote: Hello, after uploading a file, getFileName() returns me always a wrong filename, if the filename contains one of the german umlaute (like ü, ä or ö). The filename looks like: "Angebot_Tipps fï¿œr Kids.doc" (i display it BEFORE i save the name in the database). This error appears _only_ in the input-file tag, if i enter some characters in a normal input-field, everything goes fine. Is this a known error? I found nothing in the web. Is here anyone running Struts / upload running succesful with german filenames? TIA, Bart -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Storing images in SQL BLOBs
Oh right, you need to discover the location automatically. Something like this might work: request.getSession().getServletContext().getRealPath("/images"); That should give you the full path to /images. Murray Collingwood wrote: How do I find the path actual path to "/images" assuming of course that "/images" is a url reference? Is there something like $STRUTS_ROOT? Kind regards mc On 7 Sep 2005 at 14:50, Jason Lea wrote: I guess it depends if you are trying to restrict access to these images. To make all images available for anyone, put them into /images, for example. If you want to not allow any direct access to them, you could create a directory under /WEB-INF and put them there. You would then have to create something to serve the images up to browser. Or set up container managed security, put them into /auth/images, then put a security constraint on /auth/images so that only users with the required role is allowed to view the images. Murray Collingwood wrote: Hi all (Gosh, I'm starting to feel like a regular on this list...) After my experiences below I have rewritten my application to store the images in a local sub-directory, however when I ran this new version the sub-directory was created under the Tomcat/bin directory - not really appropriate. Should I be trying to reference my application directory and store the images under my "/WEB-INF" directory? Do I have to setup a special directory on the server that can be referenced by Tomcat to serve the images directly? What are others doing? Also, if you are referencing this directory in your application, is it hard-coded or do you have an entry in your 'context.xml'? What sort of entry do you use? Kind regards mc -- Jason Lea - 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.18/91 - Release Date: 6/09/2005 FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- Jason Lea
Re: Storing images in SQL BLOBs
I guess it depends if you are trying to restrict access to these images. To make all images available for anyone, put them into /images, for example. If you want to not allow any direct access to them, you could create a directory under /WEB-INF and put them there. You would then have to create something to serve the images up to browser. Or set up container managed security, put them into /auth/images, then put a security constraint on /auth/images so that only users with the required role is allowed to view the images. Murray Collingwood wrote: Hi all (Gosh, I'm starting to feel like a regular on this list...) After my experiences below I have rewritten my application to store the images in a local sub-directory, however when I ran this new version the sub-directory was created under the Tomcat/bin directory - not really appropriate. Should I be trying to reference my application directory and store the images under my "/WEB-INF" directory? Do I have to setup a special directory on the server that can be referenced by Tomcat to serve the images directly? What are others doing? Also, if you are referencing this directory in your application, is it hard-coded or do you have an entry in your 'context.xml'? What sort of entry do you use? Kind regards mc -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dealing with nulls
Whether you store nulls in your database is really a design decision you should be making based on your requirements. Taking the date example for a moment. If the date is required then it shouldn't be able to be null in the database and a record shouldn't be created until you have a valid date. However you might have optional dates. In these cases you may use null to show that the date has not been set yet. Setting the date to some funny value may mean you have to jump through hoops to filter out these dates from queries in other parts of the application. I'll see if I can whip up an example... How about a date that is used to record when some process has completed. It will be called endDate. It can be null in the database because the process has not finished yet. Now a struts action is called to update the process. My struts action talks to my application objects which do the database retrieval and populate an object representing the process. The there will be some methods such as Date getEndDate() and setEndDate(Date date) so I can rad/write to the field. Next, I need to transfer this to my form object. Struts won't deal with Date objects on a web page, it needs to deal in strings. So we will have String getEndDate() and setEndDate(String date) on the form object. These will be used by our form fields for display and populating when the form is submitted. So the tricky thing is how to convert my date into a string and the reverse when we want to read the date off the submitted form. The easiest may be to tack some extra methods onto the form object eg setEndDateAsDate(Date date). This takes the date object, which may be null, and generates a human readable version using SimpleDateFormat for example, or storing an empty string in the form object. Same goes for retrieving the endDate from the form. We might add Date getEndDateAsDate(). This method will check if the string is empty, if so it returns null. If the string isn't a valid date it returns null. If the string can be converted into a valid date using SimpleDateFormat, the date object is returned. You might also like to add an boolean isValidEndDate() method. If the string returned is not empty, the string is checked for a valid date, if it fails the user can be asked to reenter the date. This means your application doesn't have to change deal with the nulls/empty strings/incorrect dates are entered. Murray Collingwood wrote: Hi all Just like to say I really appreciate the help you guys provide us newbies. I'm looking forward to the day I will be able to help others... What convention do people normally use for dealing with NULL values from an SQL database? I can retrieve them okay. I can store them in my form class okay. But when Struts tries to display them on a form I get an exception. 1. Do you test them at the SQL retrieve and set a displayable value? eg change a null string to an empty string, change a null date to 00/00/ 2. Do you handle them in the form class with different getters and setters? eg a different property name for displaying them on the form 3. Do you handle them on the form somehow? (not sure how you would do this) 4. Or do you simply set your database so that the fields can't be null and give them defaults, ie strings always default as empty strings? Currently I'm tyring to use method 2, coding different property names in the jsp and using the getter and setter methods to transfer the null value to something that can be edited. I'm still working through some errors trying to process my date fields but wondered whether I was actually heading down the right alley? Kind regards mc FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Set the file name in html:file
Browsers don't allow you to set a file name, as it could be a security risk eg set file name to be c:\windows\someimportantfile.txt then get the form to auto submit and send the file to the server Anuradha S.Athreya wrote: Hello, In the JSP, I need to set the default file name in the JSP. I'm using html:file taglib. I'm retrieving the file name (to be set) from a bean. What is the syntax for this? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [SATURDAY] *sigh*
I am at home! and it's Sunday! (in New Zealand :) ) Dave Newton wrote: Wait, they let you guys go home on weekends?! Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using Message Resources with Tiles?
I put keys into the tile definition eg Then I just treat them as keys. Using either JSTL/EL ()or Struts tags () to fetch the text from the message resources. The tiles tags don't provide a method of getting the value directly from the resource. so I use so that the values are available in any of my tiles, then using JSTL/EL I can use ${windowTitle} in any tag as the key. eg value="${someOtherParam}"/> or Mark Womack wrote: I can't imagine that this question has not been asked before, but I could not dig up answers in the mail archives or the online documentation. I apologize in advance if there is an obvious answer that I do not see. Instead of embedding a text value in my tiles definition file like this: ... I want it to reference the text from the message resources I have already defined in my MessageResources.properties file: main.window.title=The title of the window here Maybe with something like this: ... Is there a way to do this? I'd rather have all of my localizable text in one place, namely the message properties file. There should be a way to reference strings from the message properties files by key...right? I was expecting to find an attribute on the tiles:getAsString jsp tag. Something like: or Like I said, I have to believe that this has come up as a question before. I hope there is a good answer. Thanks, -Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: MessageResources file encoding
Hi Konrad, It isn't even UTF, it's an older Java Properties file format: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html You need to use native2ascii with something like native2ascii -encoding ISO-8859-2 input.properties output.properties it turns the non-ascii characters into \u1234 format (where 1234 is the unicode value). native2ascii.exe is in one of the Java SDK directories (I think), and there is also an Ant task so you can automate the process. Konrad Billewicz wrote: I'm unable to find an easy solution for my encoding problem with file MessageResources.properties declared in struts-config.xml as: File is encoded using ISO-8859-2 (Polish) while Struts interprets it as UTF. In documentation I'm not able find any "encoding" property for this tag. I, of course, can convert file to UTF but, as usually, I wish to do what I want not what I can. ;-) Best regards, Konrad Billewicz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: carriage returns
You can get Tomcat-5's JSP compiler to remove some whitespace in conf/web.xml you can set trimSpaces to true. It will remove whitespace between tags. eg Would be reduced to but abc def would be abc def draegoon Z wrote: Hey guys, I'm finally sick of all the unwanted carriage returns created by tiles and struts tags. I searched the archives and found this trick: but it doesn't fix everything, especially comments. Has anyone else gotten sick of this and came up with a quick and clean solution? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: not catching errors...
Have you tried testing in Firefox to see if you get the same result. Internet Explorer may be confusing the issue: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q294807 "Several frequently-seen status codes have "friendly" error messages that Internet Explorer 5./x/ displays and that effectively mask the actual text message that the server sends. However, these "friendly" error messages are only displayed if the response that is sent to the client is less than a specified threshold. *For example, to see the exact text of an HTTP 500 response, the content length must be greater than or equal to 512 bytes. *" So you might have to pad out your response with commented html or something for the message to show. David Johnson wrote: Hi all I've added the following to my web.xml (thanks for the help) 500 /error.jsp 404 /error.jsp java.lang.Exception /error.jsp and I've added a global forward I invoke from "error.jsp" which points to my tiles def as follows the problem is when I cause an error (like stopping the database then trying to hit it or reloading a page that should cause an error 500), I'm not seeing my error page. am I forgetting something? -- Jason Lea
Re: [OT] MessageFormat and curly brackets
From the java docs for MessageFormat: Within a String, "''" represents a single quote. A QuotedString can contain arbitrary characters except single quotes; the surrounding single quotes are removed. An UnquotedString can contain arbitrary characters except single quotes and left curly brackets. Thus, a string that should result in the formatted message "'{0}'" can be written as "'''{'0}''" or "'''{0}'''". So at a guess, something like: String str = " not strictly struts ... but lots of smart guys here :) String str = "how place literal curly brackets in String such that MessageFormat ignores them? thanx for helping riyaz --------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: request.getCharacterEncoding always return null ?
From the java docs: getCharacterEncoding public java.lang.String getCharacterEncoding() Returns the name of the character encoding used in the body of this request. This method returns null if the request does not specify a character encoding Returns: a String containing the name of the chararacter encoding, or null if the request does not specify a character encoding So, the browser might not be sending the character encoding in the request. I think browsers won't send the encoding when default encoding is used. Some browsers might not send it at all. Lixin Chu wrote: Hi, I always get null from request.getChaaracterEncoding(), do not know why. I am using Tomcat 5.5.7, Struts 1.1. Tested IE 6.0 and FireFox. Which ever encoding I select in browser, my servlet always reprots as null from the above call. thanks for any info! li xin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSP Buffer Size
If you are using Servlet 2.4, then you can use the to specifiy a page that is included at the beginning of every jsp page. You can put page directives there. http://java.sun.com/webservices/docs/1.3/tutorial/doc/JSPIntro13.html eg /template/prelude.jspf tarek.nabil wrote: Thanks Martin. But this is exactly what I'm trying to avoid. If I use the page directive, then I would need to do that in EVERY page. My question is, is there a way I can do this with Struts in some central place only once? -Original Message- From: Martin Gainty [mailto:[EMAIL PROTECTED] Sent: Sunday, May 22, 2005 4:13 PM To: Struts Users Mailing List Subject: Re: JSP Buffer Size assuming you can handle the exception when buffer overflows <%@ page buffer="9kb" autoFlush="false" %> Martin- - Original Message - From: "tarek.nabil" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" Sent: Sunday, May 22, 2005 4:25 AM Subject: JSP Buffer Size Hi everyone, Is there some way that I can set the buffer size for all JSPs to some value other than the default 8kb without having to do it in every JSP? Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to set character encoding of the incoming request in Struts 1.2.4
I use a servlet filter to set the encoding before it reaches struts souravm wrote: Hi All, I want to set the chracter encoding of incoming http request by using HttpServletRequest.setCharacterEncoding() api. How do I do it using Struts 1.2.4 ? Does it provide any configuration parameter to do the same ? Or one has to subclass the RequestProcessor class to do the same ? Or is there any other way ? Regards, Sourav - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] Recommendation of Instant Messagging System
Hi, No experience in programming, only as a user. Look at http://www.jabber.org/ - "the Jabber protocols are free, open, public, and easily understandable; in addition, multiple implementations exist for clients <http://www.jabber.org/software/clients.shtml>, servers <http://www.jabber.org/software/servers.shtml>, components <http://www.jabber.org/software/components.shtml>, and code libraries <http://www.jabber.org/software/libraries.shtml>." Miquel Angel wrote: We are developing an application (struts 1.1 + Tomcat 5.5 + Java 1.4). One of the requirements is to implement an instant messaging system for the users of the site (the system should not be very complex). Do you mind to share your experience in using this system. We are looking for free or non free systems. Thanks in advance. Miquel Angel Segui - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: [OT] Re: ajax proj
Just a quick note/question about Craig's code below: This line ${category.label} will output the value with not xml filtering, so some values will cause incorrect xml to be generated. You should use tag to filter the <,>,',", and & characters to output <, >, ', ", and & and the same for the element Craig McClanahan wrote: On 5/2/05, Woodchuck <[EMAIL PROTECTED]> wrote: JSTL is da bomb! :) Indeed it is. If you actually need to create XML in a response to an XmlHttpRequest call from an Ajax client side gadget :-), here's an approach using a JSP 2.0 page (in xml syntax) that uses JSTL to iterate over a result set, and JSP expressions to pull out the data (copied from the Shale Use Cases example app): http://java.sun.com/jsp/jstl/core"; xmlns:jsp="http://java.sun.com/JSP/Page";> ${category.label} ${category.value} The business logic that looks up the label/value pairs for the response doesn't have a clue how it will actually be rendered, and setting up a JSP page is much easier to author than building an XML DOM in Java code. Craig --- Rick Reumann <[EMAIL PROTECTED]> wrote: Dakota Jack wrote the following on 5/2/2005 4:01 PM: The other aspect that is not discussed above is the removal of the complexity from the "page". This is where JSP, Taglibs, etc., come into the picture. And, I suspect, you two are talking about a combination of this problem (keeping the page simple) and the previous problem (using a reasonable architecture). yes. For example, take a table sort example. I like being able to use JSTL (or even a display tag if that suits you) to display the collection info into the display of the table. Doing something like this within a servlet (Action) wouldn't really be wrong, but just more difficult to maintain and more of pain to code (using StringBuffer and append bla bla). -- Rick -- Jason Lea
Re: [AGAIN, PLZ HELP] Experiences using Struts with Japanese?
Good to hear :) getting all the character encoding stuff working right can be a bit tricky Pham Anh Tuan wrote: Thank you very much, Jason, my work is completed with ur help :) Pham - Original Message - From: "Pham Anh Tuan" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" Sent: Wednesday, April 20, 2005 10:00 AM Subject: Re: [AGAIN, PLZ HELP] Experiences using Struts with Japanese? Thank you, Jason Lea, I'm very happy when I receive ur feedback! I will read it, and post reply to all you about my problem after I do follow the instructions. thank you Pham - Original Message - From: "Jason Lea" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" Sent: Wednesday, April 20, 2005 9:35 AM Subject: Re: [AGAIN, PLZ HELP] Experiences using Struts with Japanese? I setup my database to use Unicode, which is what Java uses. Then it is easier to either display the characters as UTF-8 on a webpage (so japanese/french/vietnamese etc can be shown). You can change to other encodings on the web page eg SJIS. I think you have several character set translation problems occuring. The web page may be submitting the information in SJIS format, but struts might be reading them in the default Latin-1 encoding (i forget the iso number for it). Then java treating the values as Unicode stores those values in MySql, not in SJIS format. Reading these values out of the database, they are already incorrect and so they display incorrectly. You can put a filter in front of struts to force it to use the correct character encoding, and storing the information in Unicode in the database would simplify your problems. I am trying to find a link that had a good explaination of the steps. The web page has disappeared but can be viewed here: http://web.archive.org/web/20040619054137/http://www.anassina.com/struts/i18n/i18n.html Pham Anh Tuan wrote: This is the second times I post this topic, I'm in stuck of Struts with Japanese. I use to input and show Japanese characters and save them to mySQL (set charset sjis). The jsp page which contains above, I set charset is sjis. If everything does right, japanese character will be saved in mySQL, and I could show them in Struts tag. But everything doesn't happen like that, I can input japanese characters in , saving them to mySQL, but in mySQL, them saved like Decimal NCRs, some thing like わ for each character, it's not 2 bytes character like mySQL spec said if I set my database's charset is sjis in mySQL but it's 4 bytes characters (may be Struts encodes automatically Japanese character to decimal characters before Saving To Database Action happens ?). So when I get Japanese characters from mySQL to show on JSP by , I only see decimal characters. So, plz help me and show me the way to save & show special characters like Japanese or Vietnamese to mySQL with Struts. thanks for reading! Pham -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: [AGAIN, PLZ HELP] Experiences using Struts with Japanese?
I setup my database to use Unicode, which is what Java uses. Then it is easier to either display the characters as UTF-8 on a webpage (so japanese/french/vietnamese etc can be shown). You can change to other encodings on the web page eg SJIS. I think you have several character set translation problems occuring. The web page may be submitting the information in SJIS format, but struts might be reading them in the default Latin-1 encoding (i forget the iso number for it). Then java treating the values as Unicode stores those values in MySql, not in SJIS format. Reading these values out of the database, they are already incorrect and so they display incorrectly. You can put a filter in front of struts to force it to use the correct character encoding, and storing the information in Unicode in the database would simplify your problems. I am trying to find a link that had a good explaination of the steps. The web page has disappeared but can be viewed here: http://web.archive.org/web/20040619054137/http://www.anassina.com/struts/i18n/i18n.html Pham Anh Tuan wrote: This is the second times I post this topic, I'm in stuck of Struts with Japanese. I use to input and show Japanese characters and save them to mySQL (set charset sjis). The jsp page which contains above, I set charset is sjis. If everything does right, japanese character will be saved in mySQL, and I could show them in Struts tag. But everything doesn't happen like that, I can input japanese characters in , saving them to mySQL, but in mySQL, them saved like Decimal NCRs, some thing like わ for each character, it's not 2 bytes character like mySQL spec said if I set my database's charset is sjis in mySQL but it's 4 bytes characters (may be Struts encodes automatically Japanese character to decimal characters before Saving To Database Action happens ?). So when I get Japanese characters from mySQL to show on JSP by , I only see decimal characters. So, plz help me and show me the way to save & show special characters like Japanese or Vietnamese to mySQL with Struts. thanks for reading! Pham -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: General: blankline in jsp question??
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jasper-howto.html It mentions the trimSpaces on that page. Eain Mat wrote: yes I can remove blank line in source but this will cause less readability in code. I like the option to trim whitespace in web.xml. can you please provide me more information or reference? Eain Jason Lea <[EMAIL PROTECTED]> wrote: I do this sort of thing: %>%>%> So that there are no blank lines for those parts. also for tomcat 5.5 (not sure when it was added) there is an option in the default web.xml between --> [false] --> Which gets rid of whitespace when it compiles the JSP page. Eain Mat wrote: let say I included some tag library in my jsp and everytime, I have a blank line in my source, I will have a blank line in response too. Is there way to strip off or filter out those blankline. Eain -- Jason Lea No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 2005.03.23 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: General: blankline in jsp question??
I do this sort of thing: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"; %><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"; %> So that there are no blank lines for those parts. also for tomcat 5.5 (not sure when it was added) there is an option in the default web.xml Which gets rid of whitespace when it compiles the JSP page. Eain Mat wrote: let say I included some tag library in my jsp and everytime, I have a blank line in my source, I will have a blank line in response too. Is there way to strip off or filter out those blankline. Eain -- Jason Lea -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 2005.03.23 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Place message in jsp from action?
I think you are missing the save :) try something like this: ActionMessages messages = new ActionMessages(); MessageResources resource = getResources(request); ... messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("global.error.database.problem")); saveMessages(request, messages); then in the jsp ActionErrors are being deprecated (from what i recall) and replaced with ActionMessages. Scott Purcell wrote: Hello, After I complete a successful Action, and I forward to my jsp page, I would like to display a status ... something like "New User Added". Something that operates like the ActionErrors object. I tried doing this in my Action class: ActionErrors errors = new ActionErrors(); // Get access to the message resources for this application // There's not an easy way to access the resources from an ActionForm MessageResources resources = (MessageResources)request.getAttribute( Action.MESSAGES_KEY ); // Check and see if the access number is missing ActionError newError = new ActionError("global.error.database.problem"); errors.add(ActionErrors.GLOBAL_ERROR, newError); And then tried to pull the error out (just like an form error), but the error never shows? I figured I am missing something, or possibly there is a better way to handle this? Thanks, Scott . -- Jason Lea No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 2005.03.23 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: EL Mystery
hmm, having said that, it might be weird if the default behaviour was to filter. eg comparing "${company.name} is cool" and "${company.name} is cool" ${companyName} would have the second one filtered twice. It might be possible to only filter when not inside a tag. But that might then look inconsistant. bah. Jason Lea wrote: The default for bean:write and c:out is to filter the content. Both can have filtering turned off if you wish. Shame the ${} notation filter by default :( I didn't notice that in the documentation and assumed I could replace all my c:out's with ${} which is nicer to write. Would be nice if they changed this behaviour in the next version. -- Jason Lea No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 2005.03.23 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: EL Mystery
The default for bean:write and c:out is to filter the content. Both can have filtering turned off if you wish. Shame the ${} notation filter by default :( I didn't notice that in the documentation and assumed I could replace all my c:out's with ${} which is nicer to write. Would be nice if they changed this behaviour in the next version. Leon Rosenberg wrote: So, it's as much of security risk as bean:write? I mean you could turn the filter off and get the same effect? Leon Von: Jeff Beal [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 23. März 2005 21:56 An: Struts Users Mailing List Betreff: Re: EL Mystery On Wed, 23 Mar 2005 19:38:39 +, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Can some one shed some light on this mystery? Also I have heard that using EL outside of tags can be a security problem and that it is better to use a instead. The security part of this was mentioned on the list sometime in the last couple of weeks. The tags will escape any HTML-sensitive characters, but the straight EL language does not. So, let's say that your variable 'EL' that you were using is a String: " would print: <script language="_javascript_" href="" and the user would just see the characters -- no harm done. ${EL} would just print the String, and whatever script is included in 'nastybad.js' would be executed on the end-user's machine. If you are confident that the contents of your EL variable couldn't possibly have any harmful HTML in them, go ahead and use ${EL}. -- Jeff Beal Webmedx, Inc. Pittsburgh, PA USA - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 2005.03.23 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hiding pages under WEB-INF
I hide JSPs under WEB-INF, but I leave my images, .css and .js files outside so they can be served by the web server. I use forwards in struts to handle url rewriting, instead of linking directly to the css from a .jsp eg Unless there is a reason (eg restricted access etc) I wouldn't use an action to serve these types of files. The action would have to make sure you can't traverse directories, set content mime-types etc. I imagine it would iterfere with a browsers if-modified requests causing a browser to continually download images/css/js pages every request instead of caching them. Frank W. Zammetti wrote: Jarnot Voytek Contr AU/SC wrote: > Right, js, css, and image files don't belong under web-inf. I know someone who will disagree vigorously (where are you D.J.?!?) :) Seriously though, many people DO use this technique, and you can in fact put everything under it, even the js, css, img, etc. content... For the OP... as you found out, you can't just link to anything under WEB-INF, as is the intention of that folder's protection. What you will need to do is build yourself an Action that returns the requested item, then point everything at that Action. So, something like: ... will call your Action, which presumably retrieves the referenced image and returns it. You can do this for stylesheets, scripts, whatever else you want. -- Jason Lea -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 2005.02.22 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: filter ?
Hmm, I think something like this might do it: inside your doFilter(ServletRequest request, ServletResponse response, FilterChain chain) method: HttpServletRequest req=(HttpServletRequest ) request; req.getRequestURI() Eric Lemle wrote: From inside a filter how do I get the name of the jsp that was requested? Eric D. Lemle Senior Programmer / Analyst Intermountain Health Care 36 South State Street, Suite 1100 Salt Lake City, Utah 84111 United States of America (USA) (801) 442-3688 -- e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.7 - Release Date: 2005.02.10 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Handle images path in one place
Craig McClanahan wrote: (Note that you can get the same sort of filtering that does for you, to avoid cross site scripting attacks, by using things like "" instead of "${customer.id}" if you need it.) hmm, wonder why I have always thought ${customer.id} would have escaping turned on? Maybe because defaults to doing it by default? But reading the specs it does say the same thing you say above eg you need to use to get that escaping. I think I would prefer to have escaping on for almost all of my ${} expressions with only some exceptions having them turned off. In those cases I think it would be fine to use the tag. I might have to go back and make sure my apps use now instead of the easier to use ${} expression. Unless there is some way to force escaping on for ${} expressions by default? Doesn't look like it to me :( -- Jason Lea -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.7 - Release Date: 2005.02.10 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html-el oddities
I think you are missing a dot :) cur.PrdNumber not curPrdNumber Try: Trevor Hill wrote: I'm having an interesting issue. I have a form in which the only input is a bunch of text boxes which correspond to quantities of products. The associated form thus consists of just a HashMap. My JSP page is as follows: <... header stuff ...> Product Product Number Price Quantity to add <... submit button, close form, etc> However, the output of the last TD is: which is correct except for that whole "not interpreting the EL expression" bit. I've tried using a page-scoped temporary variable (as above), I've tried directly referencing ${cur.prdNumber} in the html-el:text tag, I've checked all my TLDs and the struts-el.jar files to ensure they're in the correct place and checked the web.xml file to make sure all the TLDs are mentioned. There are no error messages in my application's log or my application server's log that would suggest some class or configuration file being out of whack. All my other taglibs (normal struts tags and jstl tags) are working just fine, and the html-el tag /seems/ to work fine from a Struts standpoint in that it makes an just like it should, but no el-evaluation. This problem doesn't appear to be specific to the mapped property "quantity", as I can try other html-el tags that directly refer to either ${curPrdNumber} or {$cur.prdNumber}, and I get the same result -- no evaluation. Am I missing something glaringly obvious? Thanks, --Trevor - This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.7 - Release Date: 2005.02.10 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OT - Evaulating JSP as internal template?
Oops, I guess I should add that I was creating email messages during a batch processing operation at 1am, so this was not generated by an action, and there was no request/response object available. Otherwise the other solution with RequestDispatcher would have worked. Jason Lea wrote: Hi, I couldn't find a way to do this, other than using Jelly: http://jakarta.apache.org/commons/jelly/ Which uses JEXL which is a EL processing engine, so it looks like JSP with EL. The Jelly tutorial has an example where you can call the Embedded object to process a jelly script file. Jelly scripts are not exactly the same though. I used it for creating some HTML email messages. William Stranathan wrote: The subject is prolly a poor way to say what I'm trying to say Does anybody know of a simple way to use JSP as an INTERNAL templating engine. For example, if I have a struts application where I'm generating an email to send, I currently have to use Velocity on the server side to put the values into the template, then send that. Is there a simple way to do the same with JSP? Would I be best served by on the server side, constructing an HTTP request to a JSP that simply pops in the request attributes into the correc place? High-level of what I want to do: ActionForward execute(mapping, form, request, response) { MyForm myform = (MyForm)form; Hashtable vals = new Hashtable(); vals.put("user",form.getUser()); vals.put("car",form.getCar()); JSPProcessor proc = new JSPProcessor(); proc.getRequestScope().put("values",vals); StringBuffer buff = proc.evaluate("WEB-INF/templates/email.jsp"); MailUtils.mail("[EMAIL PROTECTED]",buff); } Where JSPProcessor is the kind of magic I'm looking for. I don't really see anything built into the API spec, so I SUSPECT if there were anything available in Tomcat, for instance, it would be implementation specific. Not a HUGE deal, but it's kinda' a pain to have to train new folks on how to put together the JSP's AND how to put together the velocity templates. Thanks, Will - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.4 - Release Date: 2005.01.25 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OT - Evaulating JSP as internal template?
Hi, I couldn't find a way to do this, other than using Jelly: http://jakarta.apache.org/commons/jelly/ Which uses JEXL which is a EL processing engine, so it looks like JSP with EL. The Jelly tutorial has an example where you can call the Embedded object to process a jelly script file. Jelly scripts are not exactly the same though. I used it for creating some HTML email messages. William Stranathan wrote: The subject is prolly a poor way to say what I'm trying to say Does anybody know of a simple way to use JSP as an INTERNAL templating engine. For example, if I have a struts application where I'm generating an email to send, I currently have to use Velocity on the server side to put the values into the template, then send that. Is there a simple way to do the same with JSP? Would I be best served by on the server side, constructing an HTTP request to a JSP that simply pops in the request attributes into the correc place? High-level of what I want to do: ActionForward execute(mapping, form, request, response) { MyForm myform = (MyForm)form; Hashtable vals = new Hashtable(); vals.put("user",form.getUser()); vals.put("car",form.getCar()); JSPProcessor proc = new JSPProcessor(); proc.getRequestScope().put("values",vals); StringBuffer buff = proc.evaluate("WEB-INF/templates/email.jsp"); MailUtils.mail("[EMAIL PROTECTED]",buff); } Where JSPProcessor is the kind of magic I'm looking for. I don't really see anything built into the API spec, so I SUSPECT if there were anything available in Tomcat, for instance, it would be implementation specific. Not a HUGE deal, but it's kinda' a pain to have to train new folks on how to put together the JSP's AND how to put together the velocity templates. Thanks, Will - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.3 - Release Date: 2005.01.24 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: i18n & Tiles
Dakota Jack wrote: How does this solve the i18n problem? On Mon, 17 Jan 2005 03:07:27 -0600, Kishore Senji <[EMAIL PROTECTED]> wrote: On Mon, 17 Jan 2005 17:54:55 +0900, Sylvain ~ <[EMAIL PROTECTED]> wrote: By the way, I don"t want to have ONE internationilized title for all my pages, so I can't do that, it would have been too simple !! I have many pages, having different i18n titles, You can extend the main.layout and override the title for the different pages like so If you have different pages and want different results by overriding, that is a different issue altogether. Overriding does not solve the i18n problem at all so far as I can see. I really prefer Lesaint's solution to mine. I do something entirely different than either of them but different than your approach too. I make the title tag's value dynamic in the layout, e.g. . I like this because it does not tie itself to Tiles, although maybe I should switch to what Lesaint is doing. How come the French seem to be so adept at GUIs? Maybe there is just a deep sense of style in the French psyche? There are several levels to the i18n problem. The simplest is just picking the correct string to output on a particular page such as a title. This isn't necessarilly tying yourself to tiles, you could specify the title key in your action or each individual .jsp page. It certainly makes it easier to maintain. Just match up keys in tiles to keys in your application.properties files and .jsp files. Easiest way to demonstrate is a few examples: application_en_US.properties: login.title=Hello application_en_NZ.properties: login.title=Hi Mate application_en.properties: login.title=Hi In Tiles, we use the examples above because they are fine: In your layout.jsp page we use the following: That name="title" will look up the applications.properties file and pick the string depending on your locale. So we should see either "Hello","Hi Mate", or "Hi". This can also be done in JSTL (may have to set the resource bundle to be the same one struts uses) Now you say your titles need to be dynamic - it really depends on what information changes in this title. This is the next harder step in i18n, but it isn't too difficult to do: application_en_US.properties: login.title=Hello {0} {1} application_en_NZ.properties: login.title={1}, Hi Mate application_en.properties: login.title=Hi {0} {1} Above we have put in the {0} substitution points where the information will appear. If we want {1} to be their title eg Mr Mrs and {0} to be a person's name. or in JSTL (assuming we have a user object with user's name and title) We should end up with output en_US: Hello Mr Smith en_NZ: Smith, Hi Mate en: Hi Mr Smith It get's trickier when part of the text should change based on numbers eg 0 files, 1 file, 2 files as {0} file wouldn't work But the above should deal with most of the common uses -- Jason Lea No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.0 - Release Date: 2005.01.17 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to view the actual HTTP generated by a struts action.
For Mozilla + Firefox you can use this extension to view the POSTed headers http://livehttpheaders.mozdev.org/ Doesn't help if you want to see what IE is sending, some of the other suggestions would work in that case. kjc wrote: Is there a way to log the HTTP post string that is sent by the browser when clicking on buttonOps is an instance of ImageButton pattern. I'm sure readers of the group are familiar with it. Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.6.10 - Release Date: 2005.01.10 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Attributes Initialization
1. From what I see here you redirect from index.jsp to submit.do. 2. The submit.do action is defined to have validation. 3.*My guess* is that validation fails, and you are returned to your input page (input="submit.jsp") and the execute method is *not* executed 4. You submit a form from submit.jsp to submit.do, validation succeeds, execute() executes normally To fix this you would need a new action which has validation turned off (if i remember correctly, unless there is some other way to do it) eg and index.jsp should change to <%@ taglib uri="/tags/struts-logic" prefix="logic" %> Eli Segev wrote: Wendy, I know that the method is not executed, because I put a 'print' statement as the first line in the method. The 'print' statement does not appear initially in Tomcat. It does appear only after submitting the form. I also added a no-arg constructor for the action class. It is used only after a form has been submitted. Wendy Smoak <[EMAIL PROTECTED]> wrote: From: "Eli Segev" index.jsp redirect to 'submit', which is defined as a global forward as 'submit.do'. If you're redirecting to submit.do, given the configuration you've posted, SubmitAction should be executing. What do you have in execute()? Why do you think it _isn't_ executing? The thing is... typically, the execute method does whatever it needs to do, then calls mapping.getInputForward(). If execute isn't executing, how are you ever getting to your form? Here's a guess: in SubmitAction.execute(), you're putting things in the request, then *redirecting* to your form. If so, the browser will make a new request for the redirect, and the things you put in the original one will be lost. I'd have to see SubmitAction.java and whether there is anything interesting in the log files in order to offer any further guesses. I can define it as 'submit.jsp', but there is no difference in behavior. No, that's definitely not going to fix it. Everything needs to go through an action, which you seem to be doing. -- Jason Lea No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.6.9 - Release Date: 2005.01.06 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamically adding an ActionMapping
Craig McClanahan wrote: This is *exactly* where the problem lies. If one looks inside the implementation of HashMap, one sees that there are times when the internal data structures are being modified, and are in a potentially inconsistent state that would corrupt a read operation happening on a simultaneously executing thread. If you are accessing a HashMap with read and write operations on multiple threads, the only safe thing to do is lock all the reads, as well as all the writes. If someone were to attempt a change, I imagine using something like (http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/ConcurrentReaderHashMap.html) ConcurrentReaderHashMap or ConcurrentHashMap would be good starting point to avoid these locking problems. One problem would be dependency (either using java.util.concurrent for J2SE 5.0 or EDU.oswego.cs.dl.util.concurrent for earlier Java versions) -- Jason Lea -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.296 / Virus Database: 265.6.0 - Release Date: 2004-12-17 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.296 / Virus Database: 265.6.0 - Release Date: 2004.12.17 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tiles and message internationalization
An example of what you can do tiles-def.xml (.main.home defines menus and other things, and extends layout.jsp): I put the title in my layout template: layout.jsp (using JSP 2.0/JSTL/EL - you may have to set resource name to be the same as the one Struts uses): ... or using struts tags, layout.jsp: ... or a mixture of struts tags and EL (requires html-el struts tags), layout.jsp: ... The tiles:importAttribute is pulling all the values into request scope so that I can use them on this page and other tiles pages. You Xu wrote: I saw your reply as follows: But what do you put in the xml definition file? The problem is that you can not use in the JSP page and put in the xml file for the value of that title string. It won't work. - Do you Yahoo!? All your favorites on one personal page – Try My Yahoo! -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts to generate html email content
Nathan Coast wrote: Hi, Is there any way to generate content that isn't written to the ServletResponse? I'd like to use jsp / struts to generate html emails. something like this: 1) user clicks 'generate email' button. 2) struts action sets up parameters and identifies recipients. 3) delegate to a jsp to create the html email content. 4) trap the content (don't return to the user) and send as an email. 5) return a message to user confirming email has been sent. is this possible without having to re-invent a servlet container :) I have used Jelly (http://jakarta.apache.org/commons/jelly/) for this purpose. You can use JSTL/EL so it looks like a JSP page. Look at using Jelly Embedded (http://jakarta.apache.org/commons/jelly/tutorial.html#embeddingjelly) thanks Nathan -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AW: problem with unicode
I would suggest using UTF-8 encoding on your pages, and follow the the example here so that all your pages have the corrent encoding: http://web.archive.org/web/20040114232541/http://www.anassina.com/struts/i18n/i18n.html Then \u0119 should be rendered correctly as a unicode character on the web page Otto, Frank wrote: Thanks for your answer. The right character is a polish character: ? The charset in the document header is: My character table says \u0119 is ? and not ê. My test-html-file contains ê, but ? was displayed. But if I use message tag it is wrong. -Ursprüngliche Nachricht- Von: Guillaume Cottenceau [mailto:[EMAIL PROTECTED] Gesendet: Montag, 15. November 2004 10:10 An: [EMAIL PROTECTED] Betreff: Re: problem with unicode "Otto, Frank" writes: I have a problem with display of characters in latin-1. for example: The properties file contains the unicode \u0119, but the character is not displayed. If I use ę it will be displayed. I use key="my.text"/> Has someone a solution? If you're really trying to display that character in latin1, yes it will fail because this is not a latin1 character. When converting to java unicode escapes, first 128 latin1/ascii characters are unchanged and remaining 128 characters are \u0080 to \u00ff, as you can see with this: [EMAIL PROTECTED] /tmp] perl -e 'print chr($_), " " foreach 128..255' > t.p [EMAIL PROTECTED] /tmp] native2ascii -encoding latin1 t.p \u0080 \u0081 \u0082 \u0083 \u0084 \u0085 \u0086 \u0087 \u0088 \u0089 \u008a \u008b \u008c \u008d \u008e \u008f \u0090 \u0091 \u0092 \u0093 \u0094 \u0095 \u0096 \u0097 \u0098 \u0099 \u009a \u009b \u009c \u009d \u009e \u009f \u00a0 \u00a1 \u00a2 \u00a3 \u00a4 \u00a5 \u00a6 \u00a7 \u00a8 \u00a9 \u00aa \u00ab \u00ac \u00ad \u00ae \u00af \u00b0 \u00b1 \u00b2 \u00b3 \u00b4 \u00b5 \u00b6 \u00b7 \u00b8 \u00b9 \u00ba \u00bb \u00bc \u00bd \u00be \u00bf \u00c0 \u00c1 \u00c2 \u00c3 \u00c4 \u00c5 \u00c6 \u00c7 \u00c8 \u00c9 \u00ca \u00cb \u00cc \u00cd \u00ce \u00cf \u00d0 \u00d1 \u00d2 \u00d3 \u00d4 \u00d5 \u00d6 \u00d7 \u00d8 \u00d9 \u00da \u00db \u00dc \u00dd \u00de \u00df \u00e0 \u00e1 \u00e2 \u00e3 \u00e4 \u00e5 \u00e6 \u00e7 \u00e8 \u00e9 \u00ea \u00eb \u00ec \u00ed \u00ee \u00ef \u00f0 \u00f1 \u00f2 \u00f3 \u00f4 \u00f5 \u00f6 \u00f7 \u00f8 \u00f9 \u00fa \u00fb \u00fc \u00fd \u00fe \u00ff You can also verify that trying to convert to latin1 doesn't change your character: [EMAIL PROTECTED] /tmp] echo "\u0119 - \u00ea" > t.p [EMAIL PROTECTED] /tmp] native2ascii -encoding latin1 -reverse t.p \u0119 - ê Check the html sourcecode in the browser to see what's actually being transmitted. Verify the encoding/charset specified in the document header and how the character is actually encoded in the page. -- Guillaume Cottenceau - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: Internationalization of characters --UTF8 encoding
Sorry, I don't have any examples. It is certainly easier if everything is UTF-8, from web pages, through to database. Shilpa Nalgonda wrote: thanks. i tried converting data but nothing works, maybe i should try UTF-7 and see.. but can u send me examples ... -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Friday, October 29, 2004 5:29 PM To: Struts Users Mailing List Subject: Re: Internationalization of characters --UTF8 encoding Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1, Oracle 8i , and XmlRpc to write an application which is supposed to take japanese characters an insert them into database. Is there any setting in Tomcat4 where i should be giving the encoding option. And aslo i get the request from the client in the form of xml and pass that request via xmlrpc and insert into oracle database. The client sends japanese characters in Unicode , our database has caracter set of US7ASCII. select * from NLS_DATABASE_PARAMETERS where parameter = 'NLS_CHARACTERSET'; PARAMETER VALUE -- -- NLS_CHARACTERSET US7ASCII The data is being inserted as all brackets in database.'{{{' Is there any conversion i need to do while inserting in the database. Please suggest if anyone has any opinions. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] If you can't change the database to Unicode/UTF-8 encoding then you would have to convert strings going into and coming out of the database. This would be the best option for reading/writing the database. Everything else takes a lot of extra work. You maybe able to dump the database and recreate a new one as Unicode/UTF-8 and then reload the data. There may be functions in Oracle 8i has any functions that might do this for you, or perform string conversions. Another option which would be full of difficulty would be converting the strings into UTF-7 (http://www.free-definition.com/UTF-7.html) before inserting into the database, and then converting from UTF-7 to Unicode when you read from the database. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: WebApp Startup
Struts Plug-in or a Servlet 2.3 ContextListener ( http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Servlets4.html ) The ContextListener is initialised/destroyed when the context starts up and shuts down. CRANFORD, CHRIS wrote: I want to have a particular XML file read from my struts application at startup and be cached so that it does not have to be read from disk each time my menu permissions adapter needs to determine access information. How would I go about coding something like this? ___ Chris Cranford Programmer/Developer SETECH Inc. & Companies 6302 Fairview Rd, Suite 201 Charlotte, NC 28210 Phone: (704) 362-9423, Fax: (704) 362-9409, Mobile: (704) 650-1042 Email: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Internationalization of characters --UTF8 encoding
Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1, Oracle 8i , and XmlRpc to write an application which is supposed to take japanese characters an insert them into database. Is there any setting in Tomcat4 where i should be giving the encoding option. And aslo i get the request from the client in the form of xml and pass that request via xmlrpc and insert into oracle database. The client sends japanese characters in Unicode , our database has caracter set of US7ASCII. select * from NLS_DATABASE_PARAMETERS where parameter = 'NLS_CHARACTERSET'; PARAMETER VALUE -- -- NLS_CHARACTERSET US7ASCII The data is being inserted as all brackets in database.'{{{' Is there any conversion i need to do while inserting in the database. Please suggest if anyone has any opinions. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] If you can't change the database to Unicode/UTF-8 encoding then you would have to convert strings going into and coming out of the database. This would be the best option for reading/writing the database. Everything else takes a lot of extra work. You maybe able to dump the database and recreate a new one as Unicode/UTF-8 and then reload the data. There may be functions in Oracle 8i has any functions that might do this for you, or perform string conversions. Another option which would be full of difficulty would be converting the strings into UTF-7 (http://www.free-definition.com/UTF-7.html) before inserting into the database, and then converting from UTF-7 to Unicode when you read from the database. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Tiles and Internationalization
You can put what ever you like in the tile attributes. I store the resource keys so that they can be looked up depending on locale. Example - using a welcome page and a view shopping cart page In your tiles definition welcome page: ... shopping cart page: ... In your template page in your application.properties etc welcome.title=Hello cart.view.title=View Shopping Cart Christian Hesse wrote: Hi all! I have a small problem: I am creating a web-application with struts, which contains many jsp-pages. At the moment I use the concept copy & pasting the layout into each page. I read much about including parts by jsp-commands, templates and tiles and try to use tiles. But I do have one big problem with that: I have my template looking like that: I know, it looks nice, but I have the problem, that each page has to choose another title, which is in my Ressource-Properties and to make it more complicated, I develop it with internationalization. I also have to use the title in the "head"-section, but I think the reuse is no problem. How can I configure a key, which will be resolved in the RessourceBundles to give me the language- and page-dependent title? Any suggestions? Bye Christian Verschicken Sie romantische, coole und witzige Bilder per SMS! Jetzt neu bei WEB.DE FreeMail: http://freemail.web.de/?mc=021193 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Serious performance impact with iterator
If you are using tomcat you could look at the trimSpaces option for JSP page compilation in server.xml There are also filters that can be used to compress the page as it is being sent to the browser. You can also try writing out tags differently to minimise spaces produced in source eg ... ... ... The spaces inside a tag will not be output to the page. So by putting the indentations there, you can see them in the code but not the html that is sent to the browser. Eg abc will produce 'abcabcabcabc' where as abc will produce 'abc abc abc abc' JoAnn Lemm wrote: Hey All, I'm wondering if anyone else is seeing this impact. I've got an iterator within an iterator thusly: The resulting html looks like the following. Note all the empty spaces. Needless to say, this has impacted performance on the website significantly by increasing the size of the page to something ludicrous when I have more than 20 rows with 10 columns of data to display! Anyone have a solution for this? A patch somewhere? Do I resort to using *gasp* scriptlets? style='BORDER-COLLAPSE: collapse' bordercolor='#11'> align="center" bgcolor='#ff'> target="_top"> Aiken target="_top"> Glenda JoAnn Lemm - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: i18n and
oh and with JSP2.0 you could use the new replace function ${fn:replace(myBean.property," "," ")} -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: i18n and
I haven't run into this problem yet, but perhaps it depends on where this sort of thing is used. If the whole chunk of text shouldn't be wrapped then you might be able to use CSS to deal with that problem: http://www.w3.org/TR/REC-CSS2/text.html#propdef-white-space text that shouldn't wrap goes here Then you don't have messy html in your properties, and have to deal with inserting unescaped fields. I think this is a bigger problem if there is a couple of words in a chunk of text where you don't want a break - in that case I'm not so sure what the best answer is. Some people believe is dangerous :) http://www.trygve.com/doomsday.html Joe Hertz wrote: I have a number of property values that will be internationalized and need non-breaking spaces between each word in them. I could put into each space, but that 1) is going to confuse my native language translators who know nothing of HTML. 2 words in english could be 3 in language-x). 2) would be wrong. There doesn't appear to be any built in method of handling this with bean:message or anything else, so I'm about to write a custom configuration class for a separate Message Resource Bundle that will contain the properties where I want spaces displayed as " "'s I have a hard time believing no one else has run into this...so I ask the following: Do I need to do this? Is there a way of doing it without writing a custom handler? or a better way of doing it? And if not, who wants to see the code when it's done? :-) -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help! Problem with "isTokenValid"
You need 2 actions. The first saves a token, then displays the form. The 2nd action is called when the form is submitted, and the code below looks ok. I assume you either don't have an action to populate the form (eg the user opens the .jsp form directly), or the action does not save the token. When your action to process the form checks for a valid token, the token doesn't exist, so it is invalid and you return your error message. t t wrote: Hi, all, I have a Form in my application, when user click the "submit" button, an Action class will be called. There is some code like this in these class. The first time the user click the button, the error "error.transaction.token" was shown while the second time it's ok. Why? Thanks in advance! Tong if (!isTokenValid(request)) { errors.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.transaction.token")); } | | | if (!errors.isEmpty()) { this.saveErrors(request, errors); this.saveToken(request); return (mapping.getInputForward()); } __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkboxes with display tag
I think you need to be using multibox for this to work. I just did something similar recently and this is how I did it: I am using JSP2.0+JSTL+EL. Using id="row" in the display:table gives me a handle to each object in the list so I can get the id for each row. Then I use ${row.id} to use as the value for the checkbox. To do the same without JSTL I assume you would need to use: (but I haven't tested that) This gets submitted to an ActionForm with these properties: public class MyActionForm extends ActionForm { private String[] deleteList=new String[0]; public String[] getDeleteList() { return deleteId; } public void setDeleteList(String[] fileId) { this.deleteId = fileId; } public void reset(ActionMapping mapping, HttpServletRequest request) { deleteList=new String[0]; } ... } This gives me an array of all the id's corresponding to the ticked checkboxes, which I might update in a database. Hope that gives you some clues - but probably more questions :) Shabada, Gnaneshwer wrote: Hello All, I have a Struts app that I am working on and am using DisplayTag to display my search results. So far everything works fine. Now, I want to add a checkbox for each row in this Displaytag which I was able to do but unable to capture the checked values in my Action Class. Please verify the below code and let me know if you find anything missing. I am using and trying to pass memberId value when it is checked. But it takes it as literal String value. defaultsort="2" defaultorder="descending" export="true" id="memberList"> sortable="true" headerClass="sortable" href="/registration/viewRegistration.do" paramId="memberName" paramProperty="memberName" /> sortable="true" headerClass="sortable" /> href="/registration/displayEmail.do" paramId="email" paramProperty="email"/> value="true" /> Please help Thanks Gnan This email message is for the sole use of the intended recipient (s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. To reply to our email administrator directly, send an email to [EMAIL PROTECTED] Toys "R" Us, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OT: jstl equivalent of logic:present
I couldn't find a way in JSTL/EL using the standard tags. So it looks like we need a tag with that ability. In that case it probably doesn't matter if you use the logic tag or the other suggestion of the request tag. I see that the logic tag allows you to check for more than 1 role eg whereas the request tag does not, so there may be a benefit with still using the logic tag. Zoran Avtarovski wrote: I'm trying to find a way to use the isUserInRole method with the c:if tag. I tried But you can't use the isUserInRole method as an expression. I'd rather not have to cast the role into a page context string to test. Using the logic:present tag is more preferable. I only ask because I get the feeling that there's a move away from the struts tags and toward jstl. How do others do it? Zoran - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Internationalizing a Struts project
Yes, I use the setCharacterEncoding(...) in a filter on Tomcat 4.1.28 to handle UTF-8 encoded pages (mainly for communicating in Japanese, which should be a good a test as any for UTF-8). I set the encoding to UTF-8 on each page as Craig suggested so the browser knows the encoding, and use a Filter to force the requests to be UTF-8 encoded before struts reads the parameters. I don't know about other servlet containers. Perhaps those other containers are not complying to the specification. There used to be a good resource "*Struts i18n* <http://www.anassina.com/struts/i18n/i18n.html> by Aaron Rustad." which was at http://www.anassina.com/struts/i18n/i18n.html But it no longer appears to exist that showed some easy steps to make everything work nicely. [EMAIL PROTECTED] wrote: Hi, Jason. Have you tried using setCharacterEncoding(...)? For me on Tomcat 4.1.30 it showed no result at all, and other solutions available on the web state that setCharacterEncoding should work but has problems on many servlet containers. Therefore all I found refers to creating new strings from getParameter() Hiran - Hiran Chaudhuri SAG Systemhaus GmbH Elsenheimer Straße 11 80867 München Phone +49-89-54 74 21 34 Fax +49-89-54 74 21 99 -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Mittwoch, 6. Oktober 2004 22:01 To: Struts Users Mailing List Subject: Re: Internationalizing a Struts project You should only need to do the following: request.setCharacterEncoding("UTF-8") before the form is populated. I think you can do this by overriding the RequestProcessor. I use a filter to do this instead. [EMAIL PROTECTED] wrote: Hi, Craig. You hit the bull's eye. No I claim this not only to be a JSP/Servlet problem. The way you describe will cause the browser to encode all form data with UTF-8. Unfortunately the servlet container (Tomcat in my case) does not know about this. To obtain the correct parameter values, someone has to call (beware of Nullpointers and UnsupportedEncodingExceptions) new String(request.getParameter("...").getBytes("ISO-8859-1"), "UTF-8") This conversion must be applied to all parameter values. Either it is done once in Struts, or each and every Action has to convert the values Struts provides, breaking this really nice architecture of FormBeans. In Cocoon I see this type of conversion can be turned on and off by configuration. I recommend changing the RequestUtils' populate method (which I did for me), or enhancing the RequestProcessor to allow RequestUtils to be replaced by subclasses thereof so people like me can plug in their own RequestUtils. What do you think? Hiran - Hiran Chaudhuri SAG Systemhaus GmbH Elsenheimer Straße 11 80867 München Phone +49-89-54 74 21 34 Fax +49-89-54 74 21 99 -Original Message- From: Craig McClanahan [mailto:[EMAIL PROTECTED] Sent: Dienstag, 5. Oktober 2004 23:47 To: Struts Users Mailing List Subject: Re: Internationalizing a Struts project On Tue, 5 Oct 2004 16:31:14 +0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hi there. I'm working on i18n of a Struts based project. All references I find about this topic deal with using messages depending on the user's locale. Has anyone ever experienced problems with national special characters (such as currency symbols for sterling or euro? Hiran This issue is more related to the way JSP works than Struts, but here's a summary. The most important consideration for national characters is the character encoding that will be used to send the response back to the browser. Unless you ask for something different explicitly, JSP pages are always sent back in ISO-8859-1 (basically 7-bit ASCII), which will create problems with characters outside the 7-bit range. To ask for the content encoding to be set differently, you use the page directive at the top of your JSP pages, for example, to select UTF-8: <%@ page contentType="text/html;charset=UTF-8" %> If all of your national characters are produced by custom tags (such as or in the case of Struts), this should be all you need. If you also want to use literal characters in the template text of your JSP page, you have to go one step further -- actually store the source code of your JSP page in an appropriate encoding, and tell the JSP compiler what that encoding is. The details of how you save pages in a particular encoding will depend on the text editor or IDE you are using, but the mechanism to tell JSP about it is s
Re: Internationalizing a Struts project
You should only need to do the following: request.setCharacterEncoding("UTF-8") before the form is populated. I think you can do this by overriding the RequestProcessor. I use a filter to do this instead. [EMAIL PROTECTED] wrote: Hi, Craig. You hit the bull's eye. No I claim this not only to be a JSP/Servlet problem. The way you describe will cause the browser to encode all form data with UTF-8. Unfortunately the servlet container (Tomcat in my case) does not know about this. To obtain the correct parameter values, someone has to call (beware of Nullpointers and UnsupportedEncodingExceptions) new String(request.getParameter("...").getBytes("ISO-8859-1"), "UTF-8") This conversion must be applied to all parameter values. Either it is done once in Struts, or each and every Action has to convert the values Struts provides, breaking this really nice architecture of FormBeans. In Cocoon I see this type of conversion can be turned on and off by configuration. I recommend changing the RequestUtils' populate method (which I did for me), or enhancing the RequestProcessor to allow RequestUtils to be replaced by subclasses thereof so people like me can plug in their own RequestUtils. What do you think? Hiran - Hiran Chaudhuri SAG Systemhaus GmbH Elsenheimer Straße 11 80867 München Phone +49-89-54 74 21 34 Fax +49-89-54 74 21 99 -Original Message- From: Craig McClanahan [mailto:[EMAIL PROTECTED] Sent: Dienstag, 5. Oktober 2004 23:47 To: Struts Users Mailing List Subject: Re: Internationalizing a Struts project On Tue, 5 Oct 2004 16:31:14 +0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hi there. I'm working on i18n of a Struts based project. All references I find about this topic deal with using messages depending on the user's locale. Has anyone ever experienced problems with national special characters (such as currency symbols for sterling or euro? Hiran This issue is more related to the way JSP works than Struts, but here's a summary. The most important consideration for national characters is the character encoding that will be used to send the response back to the browser. Unless you ask for something different explicitly, JSP pages are always sent back in ISO-8859-1 (basically 7-bit ASCII), which will create problems with characters outside the 7-bit range. To ask for the content encoding to be set differently, you use the page directive at the top of your JSP pages, for example, to select UTF-8: <%@ page contentType="text/html;charset=UTF-8" %> If all of your national characters are produced by custom tags (such as or in the case of Struts), this should be all you need. If you also want to use literal characters in the template text of your JSP page, you have to go one step further -- actually store the source code of your JSP page in an appropriate encoding, and tell the JSP compiler what that encoding is. The details of how you save pages in a particular encoding will depend on the text editor or IDE you are using, but the mechanism to tell JSP about it is standard. So, if you also use UTF-8 encoding for your source page, you'd say: <%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" T%> Craig McClanahan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ----- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: Can I detect file size without uploading?
struts Dude wrote: Cool! I was told 'detect file size without uploading' is impossible. But you said 'might work' above, have you or anyone actually tried this?? OK, I am lazy to try this myself, but hey programmers are lazy. Well, I'm lazy too :) I just came up with the idea. Whether it works is up to the people interested in it to test the idea. From a glance at the servlet spec, this sort of thing might depend on the implementation. The servlet spec doesn't say the request object must be completely filled with the entire request when the servlet is given the object. So I assume it creates a request object, reads the header and populates it and provides an input stream for the object to use later. If you access parameters then it has to read in the stream, and then you must wait for the entire request to be sent. If you just check the headers then I assume the entire request isn't read and you can return a response before the entire request is sent by the browser. But some containers might read the entire request (though I would doubt it as that would load it all into memory). I don't need this functionality, so I won't be testing it. If you do test it, can you post back to the mailing list with your experience so others can see he result. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can I detect file size without uploading?
You could shortcut the process using a filter. You create a filter that checks the content length of a request, if it is above the threshold intead of passing the request through the normal path, you forward the request onto another action that writes out an error message without consuming the whole request. Something like this might work: public class FileUploadSizeCheck implements Filter { int maxLength = 100; public void destroy() { } public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws ServletException { if (req.getContentLength() > maxLength) { request.getRequestDispatcher("/some/new/destination").forward(req, res); } else { chain.doFilter(new UploadRequestCounter((HttpServletRequest)req),res); } } public void init(FilterConfig arg0) throws ServletException { } } Bj wrote: Hi, I have tried several ways to limit upload size but none seems to work. Each time, the request uploads the whole file before detecting it's too large. The only way to avoid this may be to configure the web/JSP server himself if it's possible (check but I think tomcat 5 doesn't) Or to find a browser which implements MAXLENGTH attribut (none ?). Or to use an applet or an activeX. Bj gus a écrit : I'm using a Struts ActionForm to upload a file using a "multipart/enc" POST. The files being uploaded are sometimes rather large and we wish to restrict them to ... 5 to 10 megs. Currently we are doing this: --- inside the effected tile ... --- inside execute() for Action processUploadAction ... final FormFile attachment= uploadForm.getAttachment(); int attachSize = attachment.getFileSize(); if (attachSize > MAXATTACHSIZE){ actionErrors.add("error.attach.toobig"); return request.findForward("fail"); } ... Now the issue with this occurs when a user uploads a large file. Let's say they are uploading a 90 megabyte file. This takes 30 minutes. Our session timeout is set to 25 minutes. The user is logged out, we get errors, and the operation fails miserably. The ideal situation would allow for me to detect the file upload size before the user uploads, and before they time out. The following issues prevent me from being able to exhibit the ideal situation: 1.) By the time I have reached the action the post has already taken place. 2.) Even in the ActionForm.validate method, I can't see the size of the file before it has been uploaded. 3.) Using the controller setting, "max-file-size" seems the viable means to handle this, but unfortunately, this seems to still not restrict the established rule before the file has been completely uploaded. Additionally, it is not clear to me as to what the controller does when this max-file-size threshold is reached -- how do I intelligently produce an error before my action is touched? Ideally, what should be happening is we should be able to detect how large the file being uploaded is before the post even occurs. For example, we could look at "request.getContentLength()" and do something smart based on that. Essentially, it looks as though I may have to create a custom request processor for my purposes because the existing functionality afforded by the Controller is inadequate for our designs. I wish to make sure that this is the case. If this is the case I take it I should start with writing an extended RequestProcessor class that overrides the processPreprocess method and then performs operations on the actual parameters/request object to make sure the content length is short enough. Any thoughts and help is appreciated. -- Gregory Class <http://gregoryclass.com> Developer Spam Arrest LLC <http://spamarrest.com> ----- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: How to escape {1} that it appears in the text?
Axel Seinsche wrote: Hi all, How can I escape curly brackets in my message bundle so that I can display {1} in my JSP? I already tried with \ or \\ but whenever I don't receive an error {1} is replaced by 'null' in the text. Hope someone can help me. http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html From that I would guess something like '{'1} should work TIA, Axel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSTL problem
Chris wrote: If you're using JSTL in struts all the object will be available without drilling through the scopes. How JSTL and Struts communicate each other? Could anybody please explain this *mysterious* thing detailly? I really want to know the black box behind JSP using JSTL and Struts taglibs , but the servlet code compiled from JSP is too hard to explore. The main points are that Struts puts form beans into either the session or request scope depending on what you configure struts to do. The JSTL looks through the different scopes in order for the bean name. So the way to tie JSTL and Struts together is to know what the name of the bean that Struts has put into the scope. From struts-config.xml you might have: When this is used with an action it is put into the session/request scope under the name 'myFormBean' So to use it in JSTL you can just use ${myFormBean.abc} to access the myFormBean.getAbc() property. Regards. Chris - Original Message - From: "Mark Lowe" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Saturday, September 25, 2004 11:29 PM Subject: Re: JSTL problem If you're using JSTL in struts all the object will be available without drilling through the scopes. In straight JSTL you'd use sessionScope. But as you're using struts you dont need to and you can decide what you want to scope to in you java or configuration of the ActionServlet.. HTH Mark On 25 Sep 2004, at 15:27, M. Onur Tokan wrote: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: using JSP2.0 / JSTL1.1 with Struts
Hi Erez, Yes, downloaded Standard 1.1 and use that in my app - it says on this page: http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html "Standard-1.1 (JSTL 1.1) requires a JSP container that supports the Java Servlet 2.4 and JavaServer Pages 2.0 specifications. Jakarta Tomcat 5 <http://jakarta.apache.org/tomcat/> supports the new specifications. The Standard-1.1 taglib has been tested with Tomcat 5.0.3." Erez Efrati wrote: Jason, Thanks for replying me though it took me sometime to try it out. What about JSTL 1.1? Do I have to download it by myself and replace the Previous 1.0 version? Or is it part of JBoss or Tomcat 5.0? Thanks again, Erez -Original Message----- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, September 16, 2004 11:49 PM To: Struts Users Mailing List Subject: Re: using JSP2.0 / JSTL1.1 with Struts Erez Efrati wrote: Hi all, Until now I've been using Struts 1.1 with JSP1.2/JSTL 1.0 with the use of JSTL EL extension for Struts tags. Html-el etc.. Now I'd like to move on and take advantage of the JSP2.0 and JST1.1 new features. I am running with JBoss 3.2.5 + Tomcat 5.0. Any special steps? Do I need to download JSTL 1.1 by myself ? Thanks in advance, Erez Don't know about the JBoss side of things. But I'm using Tomcat 5.0+JSP2.0/JSTL1.1 I guess this question is going to come again too... :) I think the main points are: 1. change the web.xml declaration to have http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4"> So that it uses Servlet 2.4 + JSP2.0 2. Tag-libs: no longer need to be specified in the web.xml, so you can remove those entries You don't use the struts-el tags, as EL is provided by the container. In the JSP you include the taglibs for example: /WEB-INF/jsp/include/prelude.jspf: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"; %><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"; %><%@ taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %><%@ taglib prefix="logic" uri="http://jakarta.apache.org/struts/tags-logic"; %><%@ taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib prefix="tiles" uri="http://jakarta.apache.org/struts/tags-tiles"; %><%@ taglib prefix="nested" uri="http://jakarta.apache.org/struts/tags-nested"; %><%@ taglib prefix="display" uri="http://displaytag.sf.net"; %> I think that is all that is required, there is an optional step 3: 3. Read the JSP2.0 spec for the newweb.xml option for controlling JSPs Which allows things like those tag-libs above to be included on every JSP page eg JSP Configuration JSPConfiguration *.jsp true UTF-8 /WEB-INF/jsp/include/prelude.jspf /WEB-INF/jsp/include/coda.jspf Let me know if I missed anything... -- Jason Lea
Re: using JSP2.0 / JSTL1.1 with Struts
Erez Efrati wrote: Hi all, Until now I've been using Struts 1.1 with JSP1.2/JSTL 1.0 with the use of JSTL EL extension for Struts tags. Html-el etc.. Now I'd like to move on and take advantage of the JSP2.0 and JST1.1 new features. I am running with JBoss 3.2.5 + Tomcat 5.0. Any special steps? Do I need to download JSTL 1.1 by myself ? Thanks in advance, Erez Don't know about the JBoss side of things. But I'm using Tomcat 5.0+JSP2.0/JSTL1.1 I guess this question is going to come again too... :) I think the main points are: 1. change the web.xml declaration to have http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4"> So that it uses Servlet 2.4 + JSP2.0 2. Tag-libs: no longer need to be specified in the web.xml, so you can remove those entries You don't use the struts-el tags, as EL is provided by the container. In the JSP you include the taglibs for example: /WEB-INF/jsp/include/prelude.jspf: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"; %><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"; %><%@ taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html"; %><%@ taglib prefix="logic" uri="http://jakarta.apache.org/struts/tags-logic"; %><%@ taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean"; %><%@ taglib prefix="tiles" uri="http://jakarta.apache.org/struts/tags-tiles"; %><%@ taglib prefix="nested" uri="http://jakarta.apache.org/struts/tags-nested"; %><%@ taglib prefix="display" uri="http://displaytag.sf.net"; %> I think that is all that is required, there is an optional step 3: 3. Read the JSP2.0 spec for the newweb.xml option for controlling JSPs Which allows things like those tag-libs above to be included on every JSP page eg JSP Configuration JSPConfiguration *.jsp true UTF-8 /WEB-INF/jsp/include/prelude.jspf /WEB-INF/jsp/include/coda.jspf Let me know if I missed anything... -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: The Tag and Drop Down Menu
Something like this in JSP1.2: assuming the Struts form bean is called 'formbean' and the property is called 'property' selected> or in JSP2.0: ${item.label} Caroline Jen wrote: To make it simple, there is a JavaBean. This JavaBean has two properties: label and value. Because I have a number of label and value pairs, I have a Collection of this JavaBean(s). To create a drop down menu, I do the following: How do I use the tag to do the same thing? __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tile Pieces Are Not Aligned
If you are using tables, then you probably want to make your 's into It sounds like there might be a lot of links, and the content page has fewer lines, so the browser is centering the content vertically. valign forces the browser to display the content at the top of the cell. eg Caroline Jen wrote: But, I did use table in my basic layout for those four pieces of tiles. The text at the top of the tile (which has all the links) on my left hand side displays at a position much higher than that of the text at the top of the 'content'tile. --- Jim Barrows <[EMAIL PROTECTED]> wrote: -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Friday, September 10, 2004 3:04 PM To: [EMAIL PROTECTED] Subject: Tile Pieces Are Not Aligned I am using the tiles feature. So far so good, all pieces are displayed. I have four pieces of tiles: topbar (always the same in every page), sidebar (always the same bunch of links in every page), lowbar (alsyas the same in every page), and the 'content' tile (which varies from page to page). The problem is with the 'content' tile, which is in the center and to the right hand side of the sidebar. The position of the first line of text in the sidebar is always MUCH HIGHER than that of the 'content' tile. That is to say, the top of those two pieces of tiles are not aligned. Is there any alignment technique? Right now, my web pages look ugly. CSS or tables. Actually the CSS purists will pretty much revoke my CSS snob priveleges for mentioning tables for formatting...but hey what the heck it's an option. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: struts-el
Woodchuck wrote: --- Craig McClanahan <[EMAIL PROTECTED]> wrote: On Fri, 10 Sep 2004 18:23:46 +1200, Jason Lea <[EMAIL PROTECTED]> wrote: Though, if you are using tomcat 5 (which has JSP2/JSTL1.1) then you don't need struts el, just use the normal struts tags as Tomcat takes care of the EL expressions. To be a little bit more verbose, this behavior is only enabled (in Tomcat 5 or any other container that implements JSP 2.0) if your web.xml file declares itself to be compatible with Servlet 2.4, by including the following text at the top: http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4"> is it good practice in general to not use live references to the various definition files in web.xml? do servlet containers cache these definition files? (ie. only fetch them once at startup?) is it possible to store all of these definition files locally and reference them all locally in web.xml? From what I understand those are not live references, they just look like URLs but they are not fetched. I think they are treated as an identifier/version. You will find the web-app_2_4.xsd file in Tomcat 5's servlet-api.jar for example thanks, woodchuck Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: struts-el
Claudia Woestheinrich wrote: Hallo, I want to uses Struts-el but I can't find the source. Where can I get it? If you download struts and unzip the file it will have 3 directories: contrib, lib and webapp look in contrib/struts-el Though, if you are using tomcat 5 (which has JSP2/JSTL1.1) then you don't need struts el, just use the normal struts tags as Tomcat takes care of the EL expressions. Thanks Claudia - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to prevent directory listing?
I think (haven't tried this myself) you can override it in your own application's web.xml eg add this to your web.xml in the appropriate place default org.apache.catalina.servlets.DefaultServlet debug 0 listings false 1 Ivan Vasquez wrote: Is it possible to prevent a particular Struts webapp from displaying directory listings? That is, global /conf/web.xml has its DefaultServlet with listings set to true, thus enabling dir listing for all apps. Can I then prevent a particular Struts webapp from doing so by setting something in the local web.xml? Thank you. Ivan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SecurityFilter Question?
struts Dude wrote: Thanks Jason. Problem solved. Wooohooo. Correct me if I am wrong, it looks like I am automatically log out after login if I do nothing after some time. How do I make session last for duration of browser life or till user log out explicitly? Yes, the user principal lives in the session. When the session expires or is invalidated you are logged out. This makes logout buttons easy too, just do session.invalidate() and the user can log in as a new user. You can manually set the session timeout on the session object (I believe), or in your web.xml you can use 30 with the number of minutes you want the session to live. Also found out that I don't need a separate login form for each different user. 1 login form for all user is allowed. duuhh me. yep I don't quiet see the need to define restricted URL in securityfilter-config.xml as Admin Page /admin/* admin if I simply add roles attribute in action mapping of struts-config.xml. All my restricted action mapping has user roles attribute rather than using path attribute e.g. path="admin/bla". I hope that is not bad practice. Using the security constraint means you can also protect static html pages too. If you have /admin/abc.html or /admin/abc.jpg these would need the user to be logged in as admin to view them. What ever is easiest for you. It can be nice to know that any thing in /admin/* needs a role of admin to access it, where as if you forget to add role="admin" to an action you might not notice. Also, it looks there is no way to use client/server side struts validation to convey error message on login form. E.g. password is incorrect. Yes, sort of. If your securityfilter-config.xml does this: /LoginError.do Then the LoginError action can put the error messages into the ActionErrors like any action does, then display the login.jsp. login.jsp can display the error messages as you would normally. You won't know whether the password or username were incorrect. So a generic try again message should be ok. ----- Original Message - From: "Jason Lea" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Tuesday, August 31, 2004 1:06 PM Subject: Re: SecurityFilter Question? struts Dude wrote: You don't have to use a filter though, you could make a base action that does puts the bean into session and have all your actions sub-class that one. Using action to put bean in Session after SecurityFilter, how is that possible when after authentication by SecurityFilter, u taken right back to /user/abc.do where u 1st request it and doesn't pass through to action attribute as specified in action-mapping of struts-config.xml? you create a base class like public class BaseAction extends Action { public ActionForward execute(...){ ... do stuff that every action needs, eg checking for/putting user bean in session } } Then your other actions do something like this public class MyFirstAction extends BaseAction { public ActionForward execute(...){ super.execute(...); ... do whatever your action does } } This way, the piece of code that you want every action to execute is in one place. I have tried to use action, after authentication, I am indeed taken back to the page /admin/logon.do or /user/logon.do and got error message in browser: HTTP Status 400 - Invalid path /admin/Logon was requested message Invalid path /admin/Logon was requested description The request sent by the client was syntactically incorrect (Invalid path /admin/Logon was requested). Is that the url you tried to access or was it something in the securityfilter-config.xml? Whatever it is, it's missing the .do at the end eg /admin/Logon.do. But if it is in the securityfilter-config.xml as a login form then it is wrong, as only administrators can access /admin/* - My action mapping is struts-conf.xml Both or won't work. --- BTW, how wud u use html:form to display login fields? I can't get struts tag to work with login fields except for using things like: Username: Password: Don't know about html:form - i use something like you have done. -- Ok, using filter (as u said) after SecurityFilter wud solve this simply but I like to stick with pure Struts approach if possible. Struts is sitll happy to use filters - it was created before filters existed. It really comes down to what you are happy with and what level of container you want your app to work with. Thanks Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea -
Re: SecurityFilter Question?
struts Dude wrote: You don't have to use a filter though, you could make a base action that does puts the bean into session and have all your actions sub-class that one. Using action to put bean in Session after SecurityFilter, how is that possible when after authentication by SecurityFilter, u taken right back to /user/abc.do where u 1st request it and doesn't pass through to action attribute as specified in action-mapping of struts-config.xml? you create a base class like public class BaseAction extends Action { public ActionForward execute(...){ ... do stuff that every action needs, eg checking for/putting user bean in session } } Then your other actions do something like this public class MyFirstAction extends BaseAction { public ActionForward execute(...){ super.execute(...); ... do whatever your action does } } This way, the piece of code that you want every action to execute is in one place. I have tried to use action, after authentication, I am indeed taken back to the page /admin/logon.do or /user/logon.do and got error message in browser: HTTP Status 400 - Invalid path /admin/Logon was requested message Invalid path /admin/Logon was requested description The request sent by the client was syntactically incorrect (Invalid path /admin/Logon was requested). Is that the url you tried to access or was it something in the securityfilter-config.xml? Whatever it is, it's missing the .do at the end eg /admin/Logon.do. But if it is in the securityfilter-config.xml as a login form then it is wrong, as only administrators can access /admin/* - My action mapping is struts-conf.xml Both or won't work. --- BTW, how wud u use html:form to display login fields? I can't get struts tag to work with login fields except for using things like: Username: Password: Don't know about html:form - i use something like you have done. -- Ok, using filter (as u said) after SecurityFilter wud solve this simply but I like to stick with pure Struts approach if possible. Struts is sitll happy to use filters - it was created before filters existed. It really comes down to what you are happy with and what level of container you want your app to work with. Thanks Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: FW: cannot compile resource bundle files...illegal character error:
Not sure about using encoding="Unicode" on javac. However I have used unicode in my java source and resource bundles. I convert them to the standard java format using native2ascii then compile those files. There is an optional ant task for this: http://ant.apache.org/manual/OptionalTasks/native2ascii.html I use ant to convert my java classes and resources in /src to /src-temp, then compile the files in /src-temp eg Shilpa Nalgonda wrote: I am not able to compile resource bundle classes, which are .java files that require unicode settings. I am using ant scrpit to compile the files. my ant scrpit look slike this: I am using jdk1.4 and ant 1.4 to compile the files. Should i chane any unicode setting? please suggest... - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSTL Tag problem!!
Sounds like you are using Tomcat 5, which allows EL expressions anywhere. eg instead of you can use ${title} It also means you don't need to use the html-el tags, just use the normal RamKumar wrote: Your works here, the problem is EL not being evaluated So I still recommend you configure the IsELIgnored page directive As you said i made IsELIgnored page directive to false, i got into a new problem that my logic-el tags are not working now. i am getting an error as "According to TLD or attribute directive in tag file, attribute property does not accept any expressions" in the following line I guess that EIs in struts-el tags won't work if you make the IsELIgnored page directive to false. I tried to convert the above logic-el tag to c:forEach. . where pageValue(pageNo) and questionValue(questionNo) are the indexed property methods.But here also i am facing a problem. The Error says the expression contains invalid expression(s): javax.servlet.jsp.el.ELException: Encountered "", expected one of ["}", ".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||", "?"] I want both JSTL and struts-el tags to work as i can't convert html-el tags. How do i do that?. Any clues?. thanks, Ramkumar On Sat, 28 Aug 2004 18:18:58 +0530, RamKumar <[EMAIL PROTECTED]> wrote: JSTL needs to config in web.xml I configured JSTL in web.xml like this. http://java.sun.com/jstl/fmt /WEB-INF/fmt.tld http://java.sun.com/jstl/fmt-rt /WEB-INF/fmt-rt.tld http://java.sun.com/jstl/core /WEB-INF/c.tld http://java.sun.com/jstl/core-rt /WEB-INF/c-rt.tld http://java.sun.com/jstl/sql /WEB-INF/sql.tld http://java.sun.com/jstl/sql-rt /WEB-INF/sql-rt.tld http://java.sun.com/jstl/x /WEB-INF/x.tld http://java.sun.com/jstl/x-rt /WEB-INF/x-rt.tld and in my jsp page i referred like this <%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c" %> Anything else i am missing here?. thanks, Ramkumar On Sat, 28 Aug 2004 18:17:42 +0800, Can Zheng <[EMAIL PROTECTED]> wrote: Seems the evaluation of El was not working. You can either set JSP configurations in the web.xml or set the IsELIgnored page directive to false in JSP pages. On Sat, 28 Aug 2004 13:37:03 +0530, RamKumar <[EMAIL PROTECTED]> wrote: Hi All, I am using JSTL in my JSP page for the first time. I am running into a problem with the following tag. and it prints in the page as "${sessionScope.SurveyCreateForm.surveyTitle}" Any clues? thanks, Ramkumar -- Best regards, Can Zheng - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Javen Fang --- Just for fun - Just do it - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ----- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Best regards, Can Zheng - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: SecurityFilter Question?
struts Dude wrote: - Original Message - From: "Jason Lea" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Sunday, August 29, 2004 11:04 PM Subject: Re: SecurityFilter Question? As for populating a User bean into a session once they are authenticated I have done this in the past with a filter. I place it after the security filter in the chain of filters. It checks if the user is logged in, if they are and there is no session bean, the filter creates+populates the bean and stores it in the session ready for any action that needs to use it. Can't u do this using an Action? Say, accessing /admin/LogAction.do invokes SecurityFilter, after authentication by SecurityFilter is passed, go directly to LogAction as below The problem comes if the user bookmarks a url like /user/abc.do, starts up their browser and goes directly to the protected URL. The security filter will take them to the login form, they submit username/password and seucirty filter authenticates them. Once they are authenticated they are redirected back to /users/abc.do - they don't pass through LogAction at all. So I normally have a filter that makes sure the bean is in session from where ever they are called. You don't have to use a filter though, you could make a base action that does puts the bean into session and have all your actions sub-class that one. validate="false"> name="success" path="/pages/Welcome.jsp"/> Within LogAction class, construct User bean from logonForm and add it to session. Is that possible or is the request parameters from logonForm lost? Can u be more specific of how u use a filter right after security filter to populate User bean and put it in Session? example: public class LoginFilter implements Filter { public static final String USER_BEAN_KEY = "USER_BEAN_KEY"; private FilterConfig filterConfig; public void init(FilterConfig config) throws ServletException { this.filterConfig = config; } public void destroy() { } public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest)req; HttpSession session = request.getSession(); if (null == session.getAttribute(USER_BEAN_KEY) && null != request.getUserPrincipal()) { session.setAttribute(USER_BEAN_KEY, request.getUserPrincipal()); // do your post authentication stuff here Principal principal = request.getUserPrincipal(); ... } chain.doFilter(req, res); } } and in the web.xml: Security Filter /* LoginFilter I am thinking of somehow constructing User bean in subclass of SimpleSecurityRealmBase, then if authentication pass, store this bean somehow and pass it along to requested Action specified in struts-config.xml. Another idea is to somehow integrate SimpleSecurityRealmBase into an Action class... Thanks In the struts config you can add a role="admin" parameter. It means struts will check that the user has that role before it allows the action to be executed. Can't remember what happens if they are not authenticated - might throw an exception that you can catch and display an error message? struts Dude wrote: Hi Jason, How do I use a login form that branch out to 2 restricted area depending on user's role using SecurityFilter? i.e. - if user has user role and log on, give access to /user/* - if user has admin role and log on, give access to /admin/* The only way I can think of how to do this is to use 2 links to 2 login forms, 1 form for each. BTW, can I assign roles for each Action in struts-config.xml so that I don't have to prefix path attribute of each Action with /user or /admin? Thanks ----- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ----- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: SecurityFilter Question?
I guess it depends on what sort of application you have. Normally, you might display a welcome page and give access to all the stuff that doesn't need a user to login. If everything requires them to be authenticated, you could just display the welcome + the login form. Once they log in, display some sort of welcome page for that user. This might have the menu of links they can use. If you use tiles you can insert a tile for a user or admin based on role eg Or use the struts logic tag which would allow only roles user and guest. Another way is just to display the link to an action in /user/*, if they click on the link and they are not authenticated or have the role of 'user' they will be directed to the login form. Once they login and they have the role of 'user' then they will get to the /user/* action they requested at the start. So you don't need to do any thing special in this case. As for populating a User bean into a session once they are authenticated I have done this in the past with a filter. I place it after the security filter in the chain of filters. It checks if the user is logged in, if they are and there is no session bean, the filter creates+populates the bean and stores it in the session ready for any action that needs to use it. In the struts config you can add a role="admin" parameter. It means struts will check that the user has that role before it allows the action to be executed. Can't remember what happens if they are not authenticated - might throw an exception that you can catch and display an error message? struts Dude wrote: Hi Jason, How do I use a login form that branch out to 2 restricted area depending on user's role using SecurityFilter? i.e. - if user has user role and log on, give access to /user/* - if user has admin role and log on, give access to /admin/* The only way I can think of how to do this is to use 2 links to 2 login forms, 1 form for each. BTW, can I assign roles for each Action in struts-config.xml so that I don't have to prefix path attribute of each Action with /user or /admin? Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SecurityFilter Question?
These should go to your login action, not the page hidden under the WEB-INF /WEB-INF/pages/Login.jsp /WEB-INF/pages/error.jsp eg /LoginFormAction.do Which should probably just forward to the /WEB-INF/pages/Login.jsp struts Dude wrote: Hi Can someone give me a few pointers on using SecurityFilter with Struts? This can save me potentially hrs of debugging. My securityfilter-config.xml is: http://www.securityfilter.org/dtd/securityfilter-config_1_1.dtd";> Admin Page /admin/* admin User Page /user/* user FORM /WEB-INF/pages/Login.jsp /WEB-INF/pages/error.jsp /index.jsp Now my struts-config.xml has something like validate="false"> name="success" path="/WEB-INF/pages/Welcome.jsp"/> And the path of every action in struts-config.xml will be prefixed with either /admin/ or /user/ except for those actions that forwards to Home page, login and free info JSP page. Now Login.jsp has a submit button that will invoke LogAction, which will put a User bean in Session once user is validated. ** Now according to document on SecurityFilter, SecurityFilter supports "unsolicited" login requests => when I press submit button on Login.jsp, is authentication by SecurityFilter class called first or authentication by LogAction called first ??? SecurityFilter does it's check first because you will have the filter in web.xml Security Filter /* So all requests will go through securtity filter first. The filter then looks for /admin/* etc in the url to decide if you need to be authenticated. ** Can I use Struts html tags in Logon.jsp to work with SecurityFilter? E.g. yes ** If authentication by SecurityFilter is processed first, then I don't really need to authenticate user in LogAction class but simply put User bean in Session, right ??? Your action "LogAction" does not need authentication from what you have in your security filter config. You could change your action so it is something like this: or Then you will have to go to /user/LogAction.do or /admin/LogAction.do, and security filter will make sure you are logged in or redirect you to the login form. Since SecurityFilter will do the authentication for me and direct page to error.jsp if validation failed. ** If validation fails, can I still queue error message (ActionError) in LogAction so that error.jsp will display it? Yes. Perhaps you should redirect to LoginError.do instead and put the ActionError in there. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Token is re-generated automatically.
I see. You have a form for adding new users. When you submit this form, it adds the user, then clears the fields and redisplays the form ready for another user to be added. After saving the record you create the new token so that the next user can be added. When you detect that the form is submitted twice (eg from pressing the back button) you display an error message on the form. The problem comes with handling this error condition. One way would be to clear the form fields when this occurs. if (!isTokenValid(request)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.transaction.token")); saveErrors(request, errors); addUserProfileForm.reset(mapping, request) return mapping.findForward("failure"); } In this case, when the invalid token is sent you will return them to the form, display the error messages but this time the form fields will be empty/reset. A new token would have already been created and the user will have to re-enter the form fields. I normally don't call the reset() method on forms. I create a method called clear() in the form bean which I use for clearing fields. On these admin pages where you might add a lot of records it can be nice to leave some fields with the last value entered as the records sometimes are closely related. Obviously clearing the main identifiers like username, password etc but fields like city or country might not change very often. PC Leung wrote: token is saved if checking is OK. saveMessages (request, actionMessages); saveToken(request); addUserProfileForm.reset(mapping, request); return mapping.findForward("success"); I add saveToken() right after resetToken() in order to do testing. The result is the same. As you describe in step 5, a new token is generated. So the token becomes eventually. Actually, it is a another duplicated submission. On Sat, 28 Aug 2004 21:50:18 +1200, Jason Lea <[EMAIL PROTECTED]> wrote: do you call saveToken() anywhere? After the resetToken() perhaps? It sounds like the following is happening: 1. server generates page with token A, page with token A submitted 2. token A is valid, record saved, tokenReset() called, saveToken() called creating token B 3. user presses back button, and resubmits old form with old token A 4. old token A does not match token B in session, user redirected to "failure" 5. server generates new page with token in session (token B) 6. user submits page with token B, which is accepted with new token B stored in session Perhaps you could post more of your action where you have anything that uses/resets tokens? PC Leung wrote: When a page is displayed with a token, data is inputted into the form. Clicking the submit button will save a record. Then click back previous page. Click the submit button again. Invalid token is detected as expected Error message displays on top of the page. However I find the token is changed. Data is still there. At this time, click the submit button once more. It will go to next page and save a record. The token becomes valid this time. Why is this so? Inside DispatchAction: if (!isTokenValid(request)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.transaction.token")); saveErrors(request, errors); return mapping.findForward("failure"); } resetToken(request); Inside struts-config.xml: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: Token is re-generated automatically.
do you call saveToken() anywhere? After the resetToken() perhaps? It sounds like the following is happening: 1. server generates page with token A, page with token A submitted 2. token A is valid, record saved, tokenReset() called, saveToken() called creating token B 3. user presses back button, and resubmits old form with old token A 4. old token A does not match token B in session, user redirected to "failure" 5. server generates new page with token in session (token B) 6. user submits page with token B, which is accepted with new token B stored in session Perhaps you could post more of your action where you have anything that uses/resets tokens? PC Leung wrote: When a page is displayed with a token, data is inputted into the form. Clicking the submit button will save a record. Then click back previous page. Click the submit button again. Invalid token is detected as expected Error message displays on top of the page. However I find the token is changed. Data is still there. At this time, click the submit button once more. It will go to next page and save a record. The token becomes valid this time. Why is this so? Inside DispatchAction: if (!isTokenValid(request)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.transaction.token")); saveErrors(request, errors); return mapping.findForward("failure"); } resetToken(request); Inside struts-config.xml: type="com.erp.quotation.AddUserProfileDispatchAction" name="addUserProfileForm" scope="request" validate="true" parameter="method" input="/AddUserProfile.jsp"> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tiles - proper way for choosing a tile dynamically
If you are using container managed security or the security filter you could use request.isUserInRole("admin") checking in the action. But Tiles also supports request.isUserInRole checking in the definition and tags eg You could probably try using this in your definition then on the page you would just use and see if the second menu overrides the first as they have the same name (I assume it does). It also works on the tiles:insert tag too, so you could use this on the page in question David Friedman wrote: Janne, You could set everything dynamically in the tile using something like this (don't quote me if you like it, just look it up!): public class TestAction extends TilesAction { public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (request.isUserInRole("admin")) { context.putAttribute("menu", new String("menu-admin.jsp")); } else { context.putAttribute("menu", new String("menu-user.jsp")); } return super.execute(mapping, form, request, response); } } Then, you don't need the unstandard:bind or EL tags, just the tiles:insert tags. For more information, I recommend you read the Tiles Advanced Features by Cedric Dumoulin. Link (from the bottom of the "Developer Guide" subsection "Tiles" page http://struts.apache.org/userGuide/dev_tiles.html) is: http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf Regards, David -Original Message- From: Janne Mattila [mailto:[EMAIL PROTECTED] Sent: Friday, August 27, 2004 3:09 AM To: [EMAIL PROTECTED] Subject: Tiles - proper way for choosing a tile dynamically I use Tiles to create pages that have their tiles selected dynamically based on some information that is created in an action. One simple example could be a menu tile, which is selected based on an attribute that is stored in session. I created simple definitions like: ... then, in menu.jsp page I include either "admin" menu or "user" menu based on the session parameter: Now the question: is this the "proper" way to do this, or is there a more elegant method? PS. if those tags confuse, they use jakarta unstandard taglib to enable JSTL to compare the object in session to typesafe enumeration values. In scriptlets this would be written simply as <% if (cd.business.Role.ADMIN.equals(session.getAttribute("role")) { %> ... _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Interesting tiles/redirect interaction problem
From what I can see here it looks like the page is already being written out when the error occurs from what I can see. You have gone to your first action, done some work, then return the mainLayout tile. The tile then starts building the response based on layout2.jsp. It includes the pages you have in the list. showBorrowerDemographics.do?detail=summary is calling an action and the result is included in the page. When the error occurs, it redirects to the applicationFailure tile, and it is included in the mainLayout. Perhaps you either need to change your applicationFailure tile so it returns a tile page instead of a complete web page. Or have showPaymentHistory throw a different exception which gets caught and returns a tile. If your main action failed it would want to throw the exception and have a whole page constructed and returned, but a tile should return a simple tile not a whole page. Jim Barrows wrote: I'm using tiles, and some of the tiles are summary pages. For instance a payment summary, it just shows the date and the amount. While the detail page shows how the payment was applied (how much to interest etc.) So my tiles definition looks like: Okay, this works... now let's say /showPaymentHistory.do encounters something catastrophic, like DB down etc. So, it throws a BusinessObjectException. Cool.. that works Now, I've never used the exception handling stuff in struts-config.xml so here's the definition: And the handler says: LogWrapper.logAlert( "Business Object Exception: " + ex.getMessage()); ActionForward forward = mapping.findForward( "applicationFailure"); return forward; and the forward has redirect = true in the struts-config.xml So. I would expect that even though the summary pagelet is throwing the exception, that it would forward to the applicationFailure tiles definition. What I didn't expect was for the entire page to end up nested inside the original page being requested. Shouldn't redirect=true do what I expect with regards to tiles? and pop to a new tiles definition rather then include it? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ApplicationProperties_es_ES
The resource bundles try to match the most specific bundle it can find eg is language and country are provided it will use that. If only language then it will try that. So the order for a locale of 'es_ES' will look for files in this order 1. ApplicationProperties_es_ES.properties 2. ApplicationProperties_es.properties 3. ApplicationProperties.properties So if you have a locale of 'es' then it will try 1. ApplicationProperties_es.properties 2. ApplicationProperties.properties If a key is missing in the most specific property, it will check the next one in the list. English example: ApplicationProperties.properties: home.greeting=Greetings ApplicationProperties.properties: home.farewell=Farewell ApplicationProperties_en.properties: home.greeting=Hello ApplicationProperties_en.properties: home.farewell=Goodbye ApplicationProperties_en_US.properties: home.greeting=Howdy ApplicationProperties_en_AU.properties: home.greeting=G'day Mate ApplicationProperties_en_NZ.properties: home.farewell=See ya So someone from en_NZ would see 'Hello' as it would use the home.greeting key from ApplicationProperties_en.properties. So someone from en_NZ would see 'See ya' as it would use the home.farewell key from ApplicationProperties_en_NZ.properties. You could put 90% of the en language into the _en file, and just put keys where things like spelling change in the country specific parts. Eric Dahnke wrote: Hello list, We're building an internationalized site, and we're having an issue with locales and resource bundles. If we have two specific resource bundles for Spanish from Spain (ApplicationProperties_es_ES.properties) and Spanish from Argentina (ApplicationProperties_es_AR.properties), one would think a browser arriving with a locale/user-agent of es_MX would be caught by one of the two es_* properties file, but infact es_MX gets the default English properties file, unless there is specifically a ApplicationProperties_es.properties file. Is this the expected behavior? Thx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: philosophical question/poll about Struts/JSTL, scriptlets
Tomcat 5 includes *"JSP Custom Tag Pooling* - The java objects instantiated for JSP Custom Tags can now be pooled and reused. This significantly boosts the performance of JSP pages which use custom tags." I seem to remember reading somewhere (can't remember where, does someone have a link) that JSPs that don't have scriptlets can have the taglib pooled. I assume this means the taglib is loaded and shared amongst each JSP that uses them, speeding up the page and reducing memory. I guess a scriplet on a page may make the web server make a local copy? I find with Tomcat 5+JSP 2.0 that writing pages with tags and EL has made them much easier to write and understand. With being able to get rid of tags and just use ${var} everywhere makes them much easier to read. -- Jason Lea
Re: Struts + Tomcat 5.0/ JSP 2.0+ JSTL
I also changed to tomcat 5.0 + JSP 2.0. You can stop using the struts-el tags and just use the normal struts tags. Erez Efrati wrote: Hi, I am working with Struts 1.1 + JST 1.0 tags. I wish to use some of the fine features of JSP 2.0 like EL expression everywhere I like instead of always putting JSTL 1.0 tag. I would also like to continue working with Struts tags such as I tried changing the header of the WEB.XML to http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";> But it wasn't enough I guess. I still got the following error: "According to TLD or attribute directive in tag file, attribute value does not accept any expressions" for using the Just to note that the html:hidden refers actually the html-el:hidden. What am I missing? Do I need another version of JSTL, Struts or what? Thanks in advance, --Erez -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: internationalization problem
(I haven't tested the following, but I have heard that it works) I believe the problem is that a different system is used for reading form fields when a file upload is used. The current Struts system doesn't use the encoding supplied, so it assumes the default Latin-1 encoding. I believe there is a patch that will use encoding supplied by the browser (not sure if this works as some browsers may not send the encoding in some circumstances). I think there is a work around though. Struts uses Commons Upload to handle the file uploads through it's own MultiPartRequestHandler. If you replace this with your own one you can set the encoding as follows: Struts will use org.apache.struts.upload.CommonsMultipartRequestHandler by default to handle extracting the parameters out of the request and populating the form. It uses the DiskFileUpload class from Commons FileUpload. It is that handler that we need to modify, to do that we could create our own using the org.apache.struts.upload.CommonsMultipartRequestHandler source as the basis. You will need to download the source to see how it works. We need to tell Struts to use ours instead of the defualt by adding this to your struts-config.xml Then to modify org.apache.struts.upload.CommonsMultipartRequestHandler by creating our my.own.MultiPartClassHandler class. We need to modify the handleRequest() method like so: // Create and configure a DiskFileUpload instance. DiskFileUpload upload = new DiskFileUpload(); upload.setHeaderEncoding("UTF-8"); // Set the maximum size before a FileUploadException will be thrown. upload.setSizeMax((int) getSizeMax(ac)); ... Then struts would read the form fields using UTF-8 instead of the default Latin-1 encoding. struts lover wrote: Hi Joe, Which examples.war are you talking about??? I dont see any examples.war. All special characters in the text fields get distorted. --- Joe Hertz <[EMAIL PROTECTED]> wrote: Are spanish characters not retained either? Are you using Tomcat, and if so, are you using the SetCharacterEncoding Filter? (Look in the Tomcat WebApps examples.war) Inquiring minds want to know this stuff :-) -Original Message- From: struts lover [mailto:[EMAIL PROTECTED] Sent: Thursday, August 19, 2004 2:48 PM To: [EMAIL PROTECTED] Subject: internationalization problem Hi, I am facing a problem and trying to solve it for many days but in vain. The user selects the locale(suppose es-spanish) and the page displays in that particular locale using the appropriate properties file. I also have a file upload on the same form. I am using enctype="multipart/form-data" in the tag. Now when I enter Arabic text in the text field, and post the form, the Arabic text is not retained. It inserts junk characters. Can anyone please help me on this issue. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: [OT] Date Localization
SimpleDateFormat sdf=new SimpleDateFormat("-MM-dd HH:mm"); TimeZone tz1 = TimeZone.getTimeZone("America/Los_Angeles"); TimeZone tz2 = TimeZone.getTimeZone("Asia/Karachi"); Date now=new Date(); //time in LA sdf.setTimeZone(tz1); System.out.println("Time in LA: "+sdf.format(now)); //time in LA sdf.setTimeZone(tz2); System.out.println("Time in Karachi: "+sdf.format(now)); has the following output: Time in LA: 2004-08-19 03:23 Time in Karachi: 2004-08-19 15:23 Viral_Thakkar wrote: Could you please provide the code snippet of this..?? -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, August 19, 2004 12:59 PM To: Struts Users Mailing List Subject: Re: [OT] Date Localization The SimpleDateFormat has a setTimeZone() method (coming from DateFormat). The locale doesn't have timezone information, locale is about language and countries. Countries may have several different timezones so there is no accurate way to map them to timezones. I normally allow users to pick their own timezone and store that in some preference settings for them. Then display date/time using that timezone. Viral_Thakkar wrote: Hi All, I have a Date stored in GMT format in database. Now I need to display this date to user depending on his/her LOCALE. I found SimpleDateFormat and few other classes to convert the Date Format, but I am not able to find how to change the Date value as per user locale. Example: Date in database : 19 August 2004 6:30 PM Date for User from India should be : 19 August 2004 1:00 PM How to achieve this .??? TIA, Viral - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: [OT] Date Localization
The SimpleDateFormat has a setTimeZone() method (coming from DateFormat). The locale doesn't have timezone information, locale is about language and countries. Countries may have several different timezones so there is no accurate way to map them to timezones. I normally allow users to pick their own timezone and store that in some preference settings for them. Then display date/time using that timezone. Viral_Thakkar wrote: Hi All, I have a Date stored in GMT format in database. Now I need to display this date to user depending on his/her LOCALE. I found SimpleDateFormat and few other classes to convert the Date Format, but I am not able to find how to change the Date value as per user locale. Example: Date in database : 19 August 2004 6:30 PM Date for User from India should be : 19 August 2004 1:00 PM How to achieve this .??? TIA, Viral - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: System.out.println
Log4j has configureAndWatch which looks for changes to the configuration file. As for commons-logging it doesn't have it yet: http://www.mail-archive.com/[EMAIL PROTECTED]/msg10152.html So the other suggestion of having an action to reload or change the level is probably your best bet right now. Woodchuck wrote: hi Shinobu, thanks for your reply. sorry, but i meant arbitrarily (at any time), rather than hard-coding logic in the code to toggle the debug flag at certain known situations. what i thought was, if possible, it would be nice if we could somehow get the debug flag to read (poll) from some configuration file or something, so that we can change this configuration file to enable/disable logging (or even level of logging) in the application (esp. running in production). i can see this being useful to minimize logging activity in production until there is a problem, then turn on logging to investigate and turn off when fixed, etc. does commons-logging allow for something like this? woodchuck --- Shinobu Kawai <[EMAIL PROTECTED]> wrote: Hi Woodchuck, how can we toggle the debug flag during runtime? is it possible? or does it require restarting the application? Depends on how you implement it, I guess. I use commons-logging, which completely depends on the underlying logging framework; log4j by default. With log4j, you can Logger#setLevel() to change logging level at runtime. Never wanted to, though... Best regards, -- Shinobu Kawai -- Shinobu Kawai <[EMAIL PROTECTED], [EMAIL PROTECTED]> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea
Re: Encoding of ApplicationResources file
Here is a link that might be useful: http://www.javaworld.com/javaworld/jw-05-2004/jw-0524-i18n.html Václavík Radek wrote: Hi, I am using resource files for internationalization of my web application. However, I am experiencing problems with character encoding. If I have some international characters (e.g. Czech) in the resource file, these do not display correctly in the generated page. I have the resource file encoded in UTF-8, as well as all the web pages. Have I missed any trick, that solves this problem? Thanks in advance. Radek _ Ing. Radek Václavík ICS Department - webmaster ZeNTIVA a.s. U Kabelovny 130, 102 37 Praha 10 Czech Republic tel. +420 267 243 296 _ -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Encoding of ApplicationResources file
Hi, You need to use native2ascii (program comes with java sdk and is also an ant method) to convert the UTF-8 (or other formats) into the java property file format which use \u I normally refer people here also for some other tips: http://www.anassina.com/struts/i18n/i18n.html But it doesn't seem to be working for me :( Main point is you need to request.setEncoding("UTF-8") on every request (well, ones that have form values being submitted). Otherwise they will be treated as normal ascii and be corrupted. Also pages need the response encoding or page encoding set to UTF-8 too. Václavík Radek wrote: Hi, I am using resource files for internationalization of my web application. However, I am experiencing problems with character encoding. If I have some international characters (e.g. Czech) in the resource file, these do not display correctly in the generated page. I have the resource file encoded in UTF-8, as well as all the web pages. Have I missed any trick, that solves this problem? Thanks in advance. Radek _ Ing. Radek Václavík ICS Department - webmaster ZeNTIVA a.s. U Kabelovny 130, 102 37 Praha 10 Czech Republic tel. +420 267 243 296 _____ -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts response character encoding.
Olve SÃther Hansen wrote: Now I am saying false things. I thought my baseLayout.jsp had this entry.. It didn't. So it is enough specifying <%@ page contentType="text/html; charset=UTF-8"%> in the base tiles file if that architecture is used. I think it that should work. But I think I ran into a problem when pre-compiling the JSP pages when using the 2.3 spec. If you don't pre-compile I think it should be ok. If you do pre-compile, each JSP is passed to the compiler and the compiler does not know the encoding, so it uses the default. This is why I ended up adding it to all pages. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts response character encoding.
iso-8859-1 is the default page encoding for web pages. To use anything else you need to tell the webserver. Use this at the top of every jsp page: <%@ page contentType="text/html; charset=UTF-8"%> Or for Tomcat 5 you can use Servelt 2.4/JSP2.0 spec and set the page encoding in the web.xml *.jsp UTF-8 Olve SÃther Hansen wrote: I have some problems using struts/tiles and UTF-8 characters embedded in an jsp page. How can I make struts/tiles respect the system default encoding, and not use iso-8859-1 for all jsp pages? This problem occurs in tomcat 4.1.29, 5.0.19 and 5.0.27. I have a struts version bundled with Appfuse, all I know is that it is from 2003-12.02 (that is 2. december). It seems like struts is hard-coding the response encoding to be ISO-8859-1, although the response-encoding is set to be UTF-8 for all requests.. In a struts-action I execute this code: log.debug("res encoding: " +response.getCharacterEncoding()); log.debug("req encoding: " +request.getCharacterEncoding()); resulting in: res encoding: ISO-8859-1 req encoding: UTF-8 I use the SpringFramework characterEncodingFilter to force utf-8. My web-browser reports the page to be encoded in utf-8. If I use iconv (a Linux program for converting files from one encoding to another) to convert a file containing utf-8 characters (norwegian characters à à Ã) to iso-8859-1, the pages displays correctly. My web-browser still reports the page as being encoded in utf-8. If I write the same Norwegian letters in a jsp page outside of struts/tiles control, the page displays without problems.. So, is there a way to make struts/tiles respect the system default encoding, and not use iso-8859-1 for all jsp pages? Hope someone can help me solve this problem, I have looked through most email archives I can find without any solution. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to read from web.xml?
Ivan Vasquez wrote: Hi, How can I read from web.xml, say, the application's display name? I've tried several things, but no luck. This isn't really Struts-specific, but I'm sure this is an easy one for many of you. Thanks, Ivan. in an struts action you should be able to use: getServlet().getServletContext().getServletContextName() from javadocs: javax.servlet.ServletContext.getServletContextName() Returns the name of this web application correponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element. (haven't tried this myself though) -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]