Re: Help with Scriptlet within jsp - Oops i know.
use ActionErrors / ActionErrors classes and html:errors tag instead of wot ur doing... its the *Struts* way of achieveing wot ur attempting to do... At 04:21 PM 12/15/2001 -0500, you wrote: Chuck Amadi wrote: Hi all, I know that this goes against the idea of Struts , but nevertheless please help if possible. I have created a web service for a particuler department. that calls from a Postgresql Database details pertaining to Planning Applications as follows Planningdb.jsp retrivieve data form database for viewing and a comments tab . Submit.jsp from the comments tab the Public enters there details and comment on the App Form . UserInfoValid from the Submit.jsp this page verifies the fields are completed and forwards to ProcessForm.jsp if valid and pass it back to the Database and if incorrect back to Submit.jsp for re-submission. Thus i have created a bean named PlanBean with the required getters and setters plus a StatusMsg Method. private String firstName,etc etc etc private String statusMsg ; public String getStatusMsg () { return statusMsg; } public void setStatusMsg (String statusMsg) { this.statusMsg = statusMsg; } public boolean isValid() { boolean valid =true; statusMsg=; if (true ) { statusMsg += (Hi there must be working!!); valid = false; } if (lastName.equals()) { statusMsg += (Last Name is Blank); valid = false; } if (address.equals()) { statusMsg += (Address is Blank); valid = false; } if (postCode.equals()) { statusMsg += (Post Code is Blank); valid = false; } if (email.equals()) { statusMsg += (Email is Blank); valid = false; } if (observation.equals()) { statusMsg += (Observations is Blank); valid = false; } return valid ; } Thus in my UserInfoValid.jsp i have the below scriplet nevertheless i a unable to to get the validation to prompt a StatusMsg as required . jsp:useBean id=planBean scope=session class=PlanBean / %-- Output list of value with invalid format , if any!! --% font color=red jsp:setProperty name=planBean property=*/ /font %! boolean valid = true ; % % if ((planBean.getFirstName()).equals()) { valid = false ; planBean.setStatusMsg(planBean.getStatusMsg() + Please enter your First Name ); } % % if ((planBean.getLastName()).equals()) { valid = false; planBean.setStatusMsg(planBean.getStatusMsg() + Please enter your Last Name ); } % % if ((planBean.getAddress()).equals()){valid = false; planBean.setStatusMsg(planBean.getStatusMsg() +Please enter your Address ); } % % if ((planBean.getEmail()).equals()){ valid = false; planBean.setStatusMsg(planBean.getStatusMsg() +Please enter your Email Address ); } % % if ((planBean.getObservation()).equals()){ valid = false; planBean.setStatusMsg(planBean.getStatusMsg() +Please enter your Comments ); } % % if (valid) { % jsp:forward page=ProcessForm.jsp / % } else { % jsp:forward page=Submit.jsp / % } % Everthing pass thru but if purposly leave out a field no action is taken by the PlanBean. Please help as this is stalling me. Cheers Chuck Amadi IT Systems Programmer -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] Try testing for null. Barry -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
using MySQL as a datasource
Hi All, I am attempting to use MySQL as a datasouce for struts to make use of the Connection Pool. I have in my struts-config.xml file the floowing for the datasource data-sources data-source set-property property=autoCommit value=false/ set-property property=description value=Example Data Source Configuration/ set-property property=driverClass value=org.gjt.mm.mysql.Driver/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=password value=some_pass/ set-property property=url value=jdbc:mysql://localhost:3306/myjsp/ set-property property=user value=monty/ /data-source /data-sources I have placed the Jars jdbc2_0-stdext.jar, struts.jar and the reuired MySQL driver jar (mysql_comp.jar) in the WEB-INF/lib directory for my application. Within the web.xml file for my application the servlet action is defined as follows : servlet servlet-nameaction/servlet-name servlet-classorg.apache.struts.action.ActionServlet/servlet-class init-param param-nameapplication/param-name param-valueorg.apache.struts.webapp.example.ApplicationResources/param-value /init-param init-param param-nameconfig/param-name param-value/WEB-INF/struts-config.xml/param-value /init-param init-param param-namedebug/param-name param-value2/param-value /init-param init-param param-namedetail/param-name param-value2/param-value /init-param init-param param-namevalidate/param-name param-valuetrue/param-value /init-param load-on-startup2/load-on-startup /servlet servlet-mapping servlet-nameaction/servlet-name url-pattern*.do/url-pattern /servlet-mapping The problem is that whenever I have the datasource my application will not run because the action servlet fails on initialisation with the following error : cannot load servlet name: action: Exception initializing application data source org.apache.struts.action.DATA_SOURCE Has anybody got any ideas on this. I have tested within my IDE that the database can be connected with the above url and user/password connections. Do I need any more configurations in web.xml or struts-config.xml ? any answers would be much appreciated, thanks in advance Marcus
Question about Ron Smith's Struts Transformer pkg
I just started looking at the Transformer package, which seems to fill a major hole in the Struts Framework. (I'm new to Struts as well, coming over from the Dark Side (MS)). My initial impression of the Transformer pkg is that it would not be called from the .jsp, but only from the Action, where it would be used both to transform the values from your ValueObj to your ActionForm, and then to transform incoming ActionForm fields back to your value object. So are the altered tags there mainly for items not included in the ActionForm? Is that why there is no htmlx:text tag? Sorry if my question is a little dense. Just trying to get my head around this. This is great work. Thanks to Ron for making it available!! Lee Torrence Princeton Financial Systems
Re: Using BeanUtils.populate()
I think you need commons-collections.jar. [EMAIL PROTECTED] wrote: Hi, I looked at Ted Husted's example (Ted's catalogue) for using BeanUtils.populate() to populate beans from a database query, and put them into an ArrayList. I am working on some code which queries an LDAP Directory and requires the same kind of functionality. I reworked Ted's example to fit my needs, but the beans never seem to get populated, so I end up with a ArrayList of empty beans! I am using the package org.apache.commons.beanutils to do this and I have tried version 1.0 and 1.1. The relevant part of the code is shown below. I may have missed something obvious, but I cannot see it! I have already verified that I am getting data from the LDAP query, and I am believe the problem lies in popuating the bean. Thanks in advance Neil * // start looping over the LDAP entries... while ( searchResults.hasMoreElements()) { LDAPEntry nextEntry = null; try { nextEntry = searchResults.next(); } catch(LDAPException e) { System.out.println(Error: + e.toString()); // Exception is thrown, go for next entry continue; } // create a HashMap to hold att/val pairs... HashMap properties = new HashMap(); LDAPAttributeSet attributeSet = nextEntry.getAttributeSet(); Enumeration allAttributes = attributeSet.getAttributes(); // loop over each attribute.. while(allAttributes.hasMoreElements()) { LDAPAttribute attrib = (LDAPAttribute)allAttributes.nextElement(); // get the current attribute name... String attributeName = attrib.getName(); // get the value(s) for this attribute... String[] Values = attrib.getStringValueArray(); // if we have at least 1 value for this attribute... if( allValues.length != 0) { properties.put(attributeName, Values); } } // now populate bean for this entry... try { //instantiate new bean to hold results... UserResult userresult = new UserResult(); BeanUtils.populate(userresult,properties); list.add(userresult); } catch (Exception e) { throw new IllegalAccessException(RequestUtils.getCollection: + e.toString()); } } ***rest of code follows... -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: dynamic images
Thanks for the reply. You cay I will most likley not want to serve the images from the database, where do you suggest I serve them from? In my case I am not using Apache, so I cannot serve them with Apache. Cheers Tony I'd recommend a custom tag for URL's that get pulled from the DB for a couple of reasons - it probably won't be long before you'll want to offload them from serving directly from the DB, so the URL could switch, scriptlets are *bad* (in a Struts environment). You'll want to direct the URL to a servlet that reads it from the DB and serves up the proper MIME type. We did this in my last extensive Struts endeavor and made the URL's part of a properties file so that for development purposes they could serve straight from a DB accessing servlet, and in a production environment the URL's generated were being served directly from Apache and the images got automatically pulled to static files from the DB when they did not exist in the cache. Erik p.s. And no, you can't nest taglibs like that. :) - Original Message - From: Sean Owen [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, November 23, 2001 3:35 AM Subject: Re: dynamic images I think you will need to do this: html:img src=%=card.getImageLink()% ... As far as I know you can't nest tags like this. If someone has a better way I'd like to see it! Sean - Original Message - From: Henrick Chua [EMAIL PROTECTED] To: Struts Users Mailing List (E-mail) [EMAIL PROTECTED] Sent: Thursday, November 22, 2001 6:58 PM Subject: dynamic images Hi! how can I display images whose source URL comes from the database? and how can I display it's corresponding alt property? I keep getting an error message on this code: html:img src=bean:write name=card property=imageLink width=168.5 height=88 border=1 align=texttop alt =bean:write name=card property=imageDescription / thanx. h -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Where should I store image files?
Hi Folks I have a jsp/servlet web app and am not sure where I should keep the image files. The image files are constantly getting added to, ie people can upload new images and they should be stored somewhere, either in a database or in a directory somewhere. I am not sure which is the best way to go. Can someone please tell me where they think I should store the images. Cheers Tony -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Where should I store image files?
I would suggest a directory. Databases can handle the binary info. But, it is not good for performance. Both will work but I would place a file path/url in the database to reference the images and store them in a directory. Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Sunday, December 16, 2001 9:24 PM To: Struts Users Mailing List Subject: Where should I store image files? Hi Folks I have a jsp/servlet web app and am not sure where I should keep the image files. The image files are constantly getting added to, ie people can upload new images and they should be stored somewhere, either in a database or in a directory somewhere. I am not sure which is the best way to go. Can someone please tell me where they think I should store the images. Cheers Tony -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Where should I store image files?
Where is a good place to put this directory. Should I put it in the directory structure which contains my webapp, ie, using tomcat, /var/tomcat4/webapps/mywebapp/images would this be ok? Or is there somewhere else which is better? Cheers Tony Phase Communcations wrote: I would suggest a directory. Databases can handle the binary info. But, it is not good for performance. Both will work but I would place a file path/url in the database to reference the images and store them in a directory. Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Sunday, December 16, 2001 9:24 PM To: Struts Users Mailing List Subject: Where should I store image files? Hi Folks I have a jsp/servlet web app and am not sure where I should keep the image files. The image files are constantly getting added to, ie people can upload new images and they should be stored somewhere, either in a database or in a directory somewhere. I am not sure which is the best way to go. Can someone please tell me where they think I should store the images. Cheers Tony -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]