Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

P-A Rosenberg

+ Follow
since Sep 22, 2005
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by P-A Rosenberg


I have a java application that sends and recieves SMS messages through a modem. For the purpose I have written a small java framework for communicating with the modem by AT commands in TEXT mode.

My problem is that it doesn't work to store and send swedish caracters in the modem, like �, �, �.

1)Is it possible to achieve this in TEXT mode or do I have to use PDU mode.
If yes, how can I configure the modem and/or convert the input format so international caracters can be used?

2) If no
I could sure use a java source code example on how to create a SMS message in PDU format.

Any help appreciated!
14 years ago

I'm trying to achive Javascript based form validation using the Struts validator framework on a Form containing a Map.

I think I know how to validate this "server side" but is it possible to use the Validator framework for the purpose and generate a javascript popup?

Copy/paste from Form:
public class OrderResourceModifyForm extends ValidatorForm
private Map timeTypePrices;
public OrderResourceModifyForm()
this.timeTypePrices = new HashMap();

public void setTimeTypePrice(String key, Object value)
this.timeTypePrices.put(key, value);

public Object getTimeTypePrice(String key)
return this.timeTypePrices.get(key);

Copy/paste from JSP:
<c:forEach var="orderResourcePrice" items="${timeTypePriceList}">
<html-el:text property="timeTypePrice(${})" value="${orderResourcePrice.pricePerHour}" />

Please help me write the field entry in my validation.xml in order to validate the input stored in the map timeTypePrices!
The attempt below doesn't do the trick...

<form name="OrderResourceModifyForm">

depends="required, float" >
<arg0 key="label.orderresource_add_edit.price_per_hour"/>


Any help is appreciated!
15 years ago

Originally posted by ajay halmandge:
To turn on servlet reloading, edit Edit install_dir/conf/context.xml and change

<Context reloadable="true">

Thanx ajay halmandge for your answer. I'm affraid the reload that you describe is not what I was after. Reload of a single application works fine, but that eats memory and is not recommended in production environment according to Tomcat doc. What I was after was possibility to reload the property file into the applciation memory on regular basis. This is what my proposed solution does. With the solution the application can be configured to read the resource from file if the timestamp on resource in memory is older than a specified time.
Thank you anyway
16 years ago

Originally posted by Hari patnaik:

I went to the site & in the example given there don't work as stated.

I used this example as template and I got it to work.

Have you downloaded and added the JAR files correctly? What error msg do you get?

//P-A R
[ November 24, 2005: Message edited by: P-A Rosenberg ]
16 years ago
Hi again,
To whom it may concern...
This problem has now been solved.
The solution was to create a MessageResourceFactory that extends MessageResourcesFactory and define it in struts-config.xml.

null="false" />

public class MyMessageResourceFactory extends MessageResourcesFactory
public MessageResources createResources(String config)
return new MyMessageResources(this, config, this.returnNull);

public class MyMessageResources extends MessageResources

public MyMessageResources(MessageResourcesFactory factory, String config, boolean returnNull)
super(factory, config, returnNull);

public String getMessage(Locale locale, String key)
// get the configuration for the specified locale
Configuration resource = getConfiguration(this.config + "_" + locale.getLanguage() + ".properties");

if(resource == null || !resource.containsKey(key))
// look for the key in the root configuration
resource = getConfiguration(this.config + ".properties");
return resource != null ? resource.getString(key,null) : null;

private Configuration getConfiguration(String name)
Configuration configuration = null;
URL url = Thread.currentThread().getContextClassLoader().getResource(name);
if(url != null)
PropertiesConfiguration pc = new PropertiesConfiguration();
FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
strategy.setRefreshDelay(10000); //Milli seconds

configuration = pc;
catch(ConfigurationException e)
//Logg it

return configuration;


I didn't sove this myself so I might not be able to answer questions on it.. . The example have to be modified to suite the specific project.

//P-A R
16 years ago
Start here.
You should find installation guides, tutorials, newbie faq etc.
16 years ago
I recently used this one, it was well documented, easy to understand and use.


P.s Search this forum for paging and you will find this question asked before Ds.
16 years ago
Is there a way to include a linebreak within a msg resource item and have it displayed as a linebreak when displaying the message with the bean:message tag?

I would like to do this:
my.resource=A line with <br/> a linebreak.

And have it displayed on my JSP page as:
"A line with
a linebreak."
when using <bean:message key="my.resource"/>

The question also applies when reading a string from a database, can it contain linebreaks that will be interpreted as a linebreak when displayed with a struts tag?


Hi again.
This problem have been solved by reading the documentation... doh... :roll:

bean:write has a filter attribute that can set to false to disable the feature that rewrites any "characters that are sensitive in HTML". This way a <br/> tag can be placed in e.g. a database and it will be interpreted as a HTML tagg when rendered.

bean:message seems to work OK with linebreaks in resources located in resource file. I guess I did something else wrong when trying this last time.
[ November 24, 2005: Message edited by: P-A Rosenberg ]
16 years ago

Originally posted by Merrill Higginson:
It is important to realize, though, that in order to refresh the message resource file, it is NOT necessary to restart the SERVER. It IS necessary to restart the APPLICATION. Restarting the application is much faster than restarting the server.

I'm not sure I understand what you mean by restarting the application, not the server. Can this be done when using Tomcat?
Is it reload yo refer to?
It seems like the reload option in Tomcat causes memory leaks and the server will run out of memory after X repeated reload actions. I have been recommended not to use reload in production environment due to this problem.
Can you please explain further what you mean by relaoding the application.

I have found this example and the author claims that he go it to work. I can't get the resource to reload this way but maybee someone can tell me what is wrong with the example?

[ November 08, 2005: Message edited by: P-A Rosenberg ]
16 years ago

1) I would create the bean in my Action class and register the bean to the session or the request that will make it available to the JSP page.

2) Here's some info on the el library:
You will find the taglib reference links in the menu to the left.

Hope it helped.
16 years ago
I'm using Struts message-resources and it works fine. I wonder if there is a way to configure the struts framework to reload the properties red from the resource file without restarting the webserver? I wold like to be able to reload the properties upon change, alternatively reload the property file every 30 minutes or so. Is there a way to do this?

I have searched the web on it and seen the question asked. The only solution I have found on this issue is to use other ways to handle properties and avoid message-resources.

I'm using Tomcat 5.5.9 and struts 1.2.7.

null="false" />

Property file:

<bean:message key=""/>

Help is appreciated!
16 years ago
I have a fairly new laptop with a DVD burner. I can burn DVDs that work in my computer but they don't work in my region 2 DVD player. The DVD that doesn't work is a movie burned from ISO format. DVD Decryptor displays the following informatin when loading the ISO in the program:
Label: <titel of ISO>
Region: 1;2;3;4;5;6;7;8
RCE Protection: NO
Copy right protection none.

I found a setting in the device manager (Win XP pro) when choosing properties on the DVD recorder I can choose a tab named DVD-Degion. There I can change the setting from "Region: Not Set" to for example Region 2 that would be correct for me. This setting can be changed only five times so I really would like to know what I do before I actually chage the setting.
Can anyone tell me if changing this setting would be the correct thing to do and if it's likely that it will solve my problem?

Thanx' in advance.
16 years ago

Is there any difference on how to configure xml based validation in struts 1.2.4 vs 1.2.7?

I have a working prototype in which the validator works fine with 1.2.4 but doesn't work at all when the struts.jar is updated.

As far as I understand I do it all according to the instructions online and according to examples on this site. Since it's working with the old jar it can't be all that wrong set up.

With the new jar I get the following error msg in the logg:
2005-10-28 19:03:48,128 ERROR ( struts.validator.ValidatorForm - org.apache.
struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.Validat
orAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet
org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateReq
uired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.F
ield, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest)
at org.apache.commons.validator.ValidatorAction.loadValidationMethod(
at org.apache.commons.validator.ValidatorAction.executeValidationMethod(
at org.apache.commons.validator.Field.validateForRule(
at org.apache.commons.validator.Field.validate(
at org.apache.commons.validator.Form.validate(
at org.apache.commons.validator.Validator.validate(
at org.apache.struts.validator.ValidatorForm.validate(
at org.apache.struts.action.RequestProcessor.processValidate(
at org.apache.struts.action.RequestProcessor.process(
at org.apache.struts.action.ActionServlet.process(
at se.vodafone.proweb.web.action.ProwebActionServlet.process(
at org.apache.struts.action.ActionServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
at org.apache.catalina.core.ApplicationFilterChain.doFilter(

at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11P
at org.apache.tomcat.util.threads.ThreadPool$

I searched this formum for the problem and found a thread on the submect. The problem then was that the attribute errors.required were missing in the MessageResources file, this doesn't seem to be my problem.

Please post any ideas on what can be wrong.
Thank you
//P-A R

I finally solved the problem. I had updated the struts.jar but not the other jar files beloning to stuts, among them commons-validator.jar. Also the file validator-rules.xml had some changes in the new version.
//P-A R
[ October 31, 2005: Message edited by: P-A Rosenberg ]
16 years ago
Hi and thanx' for the response.

"but the action you would have used to populate the jsp, would also be used to set the values. actually come to think of it, thats all struts does."

I realize that actions can be used to pre populate a form but I don't realize the power of actions when it comes to read information from a database and display it on a page with just information. Please convince me!

Lets say I have a simple web where a user can logg in and based on the user_id of the user the web displays all registered details about the user that logged in, Name, address etc. No forms are used on the page. Do I gain anything from using struts in this situation?

I have built a model layer with service classes, one of them is a userService that uses Spring to retrieve data from an Oracle database through stored procedures. The service class creates a user object called userDTO and populates this object with all information about a user. This object is returned to my userBean class and made available to the JSP page through the user of jsp:useBean and jsp:getProperty. If I use an action class the action class can call the service class instead and retrieve the userDTO object. If I were to populate a form I would set the attributes of my actionform to the values from the userDTO and have my form pre-populated.

What do I do when I don't have a form to populate?
How can I make my userDTO object available for my JSP page so I can use the syntax to display the name of the user?

Ps. I wasn't aware that I chose an inappropriate nickname, I used an abreviation of my first and lastname and it ended up as the bad word, I have changed it =)

Thankyou for your time.
16 years ago
I'm using a combination of struts and JSP, I use jsp:useBean to call a Bean class that returns objects used to populate my jsp pages. I'm using jsp:setProperty to set attributes in the bean used to determine what information to retrieve from the database.

This works well:
<jsp:useBean id="userbean" scope="session" class="mybeans.UserBean"/>
<jsp:setProperty name="userbean" property="userId" value="12345"/>

I would like to send a variable from my JSP page into the value attribute of the setProperty tagg, like this:
<jsp:useBean id="userbean" scope="session" class="mybeans.UserBean"/>
<jsp:setProperty name="userbean" property="userId" value="${user_id}"/>

This is not supported by the setProperty tag, is there another way to do it? Does anyone undstand what I try to do and have a solution on it?

I guess there is a "struts way" to do it. I know that I'm supposed to use actions to populate my JSP pages but since my webb only contains information and not any user input I found it overkill to build action classes just to populate the jsp pages with information from my database. I have searched the webb for hours but I don't seem to get it...

Thanx in advance
16 years ago