RE: [OT ]Re: obtaining server URL (or ip and port) from plugin

2006-03-16 Thread Wojciech Ciesielski
> even if it would work, how can you guarantee it resolves the proper
> hostname? the default linux installation resolves
> InetAdress.getLocalhost() to "localhost" until you remove the
> 127.0.0.1 line from your etc/hosts.

Right now the port was the problem. We are not using name-based virtual
hosts and IP would be sufficient. And it's easy to get from request by the
master server when slave is calling
http://my-master:8080/master-app/register-slave.do.

> thinking further, you don't need to fake anything, you could define
> your own connector in tomcat config and let him connect to the master
> and maintain the connection for incoming requests. I'm not quite sure
> whether you can easily switch connectors under tomcat or whatever jsp
> engine you are using, but it can be patched :-)

Another reason for such architecture was ease and speed of development. Most
of actions (for example associated with configuration) called by
master-server are also available from slave's admin console. So when we
implement one receiver for either master call or web admin form then we have
receiver for the other.
 
> However, once you leave the company for a better job, they will have
> to rewrite the complete load balancing or hire someone with good
> research skills, to find this threat und understand the design
> decision :-)

Blah, there are a lot of _interesting_ design and architecture decisions in
this company. It's called innovative :D

Wojtek



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT ]Re: obtaining server URL (or ip and port) from plugin

2006-03-16 Thread Wojciech Ciesielski
I didn't expect to trigger such an elaborate discussion ;-)

> Personally, I still think that parsing the server.xml and the
> context.xml  or whatever config files the webserver is using is the
> second best option.

There is another problem - how can you get path to tomcat root directory?
It's not that obvious... I can easily obtain real absolute path to directory
where application is deployed but it does not have to be within tomcat
(context registered outside tomcat root). Also acquiring working directory
from java system properties is not ok because it changes - for example when
tomcat is launched from within Eclipse during development then java working
dir is set to Eclipse home...

> The best option imho would be simply configure it with an external
> configuration file / system and don't spend too much time with magic
> and trickery.

The point is that we are preparing processing system with unknown
(dynamically changing) amount of slave servers. What we were trying to
achieve is:

- ease of deployment on 20-100 machines. That's why setting different params
in some config file for each server, packaging the WAR and sending it to the
server would be pain in the ... ;-) It's also a reason for choosing
tomcat-deployed web-apps as processing units - it's very easy to deploy on
multiple machines...

- possibility of coexistence of different versions of processing software on
one machine. It's up to master application what servers are going to be used
at particular processing

- ability to easily access particular processing unit, see it's statistics
and logs, alter it's configuration etc. That's why using web-applications
with some administration tools was chosen




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT ]Re: obtaining server URL (or ip and port) from plugin

2006-03-16 Thread Wojciech Ciesielski
OK, thank you all. I thought that it's possible in some easy way through 
J2EE/Struts API. If not we will try to work around it somehow...


Reagards,
Wojtek


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT ]Re: obtaining server URL (or ip and port) from plugin

2006-03-16 Thread Wojciech Ciesielski



Hehe, don't feel bad... I was *this* close to replying with pretty much
the same thing you did, I realized I would have been wrong just before I
clicked Send :)
  
So may be I should apologize for lack of precision in initial post :-) 
Absolutely no offense taken anyway and thanks for will to assist.


Wojtek

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT ]Re: obtaining server URL (or ip and port) from plugin

2006-03-16 Thread Wojciech Ciesielski



[EMAIL PROTECTED] wrote:
Assuming all of the "slaves" know the id of the "master", then maybe you 
have a RegisterServlet that's called by a slave processing servers during 
their init? http://javaalmanac.com/egs/javax.servlet/GetReqUrl.html


-Dennis
  
The problem is that slaves know master's URL but master also needs to 
know URL of slave server because it calls their methods (like 
http://myslave:8080/myProcessingApp/process.do) with tasks to process. 
And I can't find a good way to determine URL of slave servers :-/


Wojtek


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: obtaining server URL (or ip and port) from plugin

2006-03-16 Thread Wojciech Ciesielski




I need to find URL to my application 
(http://myhost:8080/myAppContext) from within init() method of struts 
plugin (implementing PlugIn interface). Any ideas how can I do this 
programatically without specifying it explicitly in one of 
application configuration files?
You can't do it, in any part of your web-app! But what do you need 
your application URL for?

Ciao
Antonio
We are trying to create distributed computing environment based on 
web-apps with one master server where multiple processing servers 
register themselves. Communication is done by calling action via HTTP. 
And therefore I have to let master server know about URL of processing 
server interface...


Wojtek

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: newbie guestion: JSTL Expression language

2006-03-16 Thread Wojciech Ciesielski



Morten Andersen wrote:

I want to use JSTL to check the role of the user (it can be one of many)

I'm new to JSTL so even the simplest things gives me problems:

I've set the role using request.setAttribute("role" , role);

This tag:


Prints out the role fine

While the following statements are newer true:

 
   The role is editor
 

 
   The role is editor
 

Where do I go wrong?


test is wrong :-) It should be

test="${role eq 'editor'}

if you want to compare with strings or

test="${role eq editor}

if you have variable "editor" in page/request/session scope with value 
you want to check against


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



obtaining server URL (or ip and port) from plugin

2006-03-16 Thread Wojciech Ciesielski

Hi there,

I need to find URL to my application (http://myhost:8080/myAppContext) 
from within init() method of struts plugin (implementing PlugIn 
interface). Any ideas how can I do this programatically without 
specifying it explicitly in one of application configuration files?


Thanks in advance,

Wojtek

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: SOLVED:RE: Please help! I have been looling at this problem for two days

2005-09-22 Thread Wojciech Ciesielski
> Hi Vijaya,
> 
> It turn out that I did not put the jbossall-client.jar in the lib/
> directory of myApplication. After I put the jbossall-client.jar in the
> lib/ directory, thing works fine. I really don't know why none of the log
> statements were never printed when my action class execute method was
> called. I may be due to class loading issue. Exception was already throw
> by the time the method execute got called by the Servlet engine.
> 
> Thank you for your efforts.

That's why I've asked about your appserver - you haven't answered... ;-)



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



JSF Vs Struts

2005-09-21 Thread Wojciech Ciesielski
Hi there,

I am quite experienced with Struts - I've started learning it when JSF where
just in development phase...

Right now JSF became java standard - and it's supported by tools like
MyEclipse and Exadel Studio.

So - I've got two questions:

1. is it difficult to switch from Struts to JSF for Struts-enabled ;-)
developer. How steep is the learning curve?

2. What are the benefits of such a switch apart from choosing more
standarized solution which appears to have more prospects for future?

Regards,

Wojtek





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Please help! I have been looling at this problem for two days

2005-09-20 Thread Wojciech Ciesielski
What's the appserver? Jboss or Tomcat?

It seems that you do not have libraries containing javax.ejb.* packages in
server lib directory...




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Default locale in VM

2005-09-20 Thread Wojciech Ciesielski
How can I set default locale within my JVM (Jboss server instance) ?

Wojtek



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Validator and locale

2005-09-20 Thread Wojciech Ciesielski
Hi there,

Where can I specify what locale should Validator use? I have problems with
float numbers which in Poland are represented as ##,## while Validator float
rule is complaining about ##.## format...

I have session scope LOCALE set by request filter to pl_PL already but it
doesn't help :-/

TIA

Wojtek





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Validate array

2005-09-20 Thread Wojciech Ciesielski
> Hello,
>   Actually yes there is a validate method if your actionform extends
> dynaActionform
> the 'bad side' will be that you have declared all properties, (I suppose
> to
> avoid writing java code) and then you end upt writing code for
> validation..
> 
> probably It won't be a  nice solution, but that's one
> the other one I suppose Is to write your own custom validator..

No, he is not forced to declare attributes (it would make using
DynaActionForm sensless). Just use
org.apache.commons.beanutils.PropertyUtils:

String foo = 
(String) PropertyUtils.getSimpleProperty(form, "foo");
String bar = 
(String) PropertyUtils.getSimpleProperty(form, "bar");
Boolean baz = 
(Boolean) PropertyUtils.getSimpleProperty(form, "baz");
String[] mice = 
(String[]) PropertyUtils.getProperty(form, "blindMice");

Etc...



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Validate array

2005-09-20 Thread Wojciech Ciesielski
> i use DynaActionForm and i think there is not validate method.
> Should i use ActionForm ?

I think you may use MyActionForm extends DynaActionForm, just override
validate method and you're OK.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Parameters and URL

2005-09-20 Thread Wojciech Ciesielski
> I've got a little question regarding the -Tag.
> 
> Is it correct when I have this in a jsp:
>  paramName="objekt" paramId="objekteId" paramProperty="objekteId">


No, it's not correct. In action parameter should be ONLY the actio (ie
"/admin_objekte_new.do"). NO PARAMS. If you want to add params manually to
string use href instead of action. If you want to use action you have to use
maps of parameters or paramId/paramName/paramProperty if there is only one
URL-passed parameter.





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Validate array

2005-09-20 Thread Wojciech Ciesielski
> how can i validate an array of Long and check that addNumber[] is > 0
> and < 99.99 ?
> 
>  type="org.apache.struts.action.DynaActionForm">
> 
> 

What kind of validation do you use? FormValidator and XML validation rules?
Still - you can override validate() method, call super.validate() and do
some additional validation as you need...



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: HTML-Reset-botton works only before submit

2005-09-19 Thread Wojciech Ciesielski
> thank you very much for your answer!
> But when I validate and I've have a error
> I would like that the wrong typing is still
> displayed that the user can see what was wrong!
> Only after the reset button is clicked the values should be
> cleared!
> Is there a good possibility?

Reset button usually works as
clear-what-I-have-changed-since-page-was-loaded button, not clearing the
form. So on page displaying submitted data in order to correct data - reset
sets fields to what was submitted.

If you want to clear form:

1. javascript: setting values to empty (so you can clear without reloading)
2. you probably have two actions like showMyForm.do and updateData.do - send
user again to first action with form (showMyForm.do) - it's easier but
requires reloading page



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: a little bit OT: Calendar misbehaviour

2005-09-19 Thread Wojciech Ciesielski
> You can try use the SimpleDateFormat class in java.text to parse the
> time string.

That's what I am doing:
> > Java.sql.Timestamp toReturn;
> > SimpleDateFormat dateFormatTime("HH:mm");
> > Calendar cal = new GregorianCalendar();
> > cal.setTime(dateFormatTime.parse(timeString));
> > toReturn = new Timestamp(cal.getTimeInMillis());

The problem is that I need to get Timestamp object but I can't find a way to
set it... Apart from manual calculation of timestamp value based on
Calendar.getField() ...

Wojtek



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: a little bit OT: Calendar misbehaviour

2005-09-19 Thread Wojciech Ciesielski
> 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]



RE: HTML-Reset-botton works only before submit

2005-09-19 Thread Wojciech Ciesielski
> So my question is:
> 
> Do I jave to use a javascript function?
> Is it possible to map 
> with the reset-method in the ActionForm?
> I didn't manage this.Thanks for any advice
> 
> Nice greetings

You need to reset form - after submiting form instance with data is still in
the request when it's forwarded to form...

There are several solutions:
If you validate manually (by calling validate() method within action):
1. call form's reset() method if validation fails
or
2. set redirect=yes for forward mapping leading from form validation action
to form displaying action

If you validate it by extending ValidatorForm - add something like this to
your form's validate method:

ActionErrors toRet = super.validate();
If(!toRet.isEmpty()) reset();
Return toRet;



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Validator woes, modifying the input forward on the fly?

2005-09-19 Thread Wojciech Ciesielski
> Hi I have a situation like this:
> User clicks on /viewUser.do?id=4 action, which loads the specific user
> with
> id4 to be viewed.
> On that page is a form, the form is submitted, if some part of the xml
> validation fails I need to return back to /viewUser.do?id=4.  It would be
> ideal if the information from the form could be retained.  I can set my
> input forward to be: input="/viewUser.do" but somehow I need to access
> that
> and add the parameter id=4 to it after the xml validation takes place, but
> before the new page is requested.  Is there any possible way to do this?


Use ActionRedirect class in your STRUTS Action's execute:

ActionRedirect ar = new
ActionRedirect(mapping.findForward("myRedirectForward");
ar.addParameter("id",yourId);
return ar;

and it should work :]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



a little bit OT: Calendar misbehaviour

2005-09-19 Thread Wojciech Ciesielski
Hi there,

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?

TIA



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Timezone

2005-09-18 Thread Wojciech Ciesielski
I've found out that the problem was with default timezone when JBoss was
started within Eclipse. If I run it standalone with run.bat - everything
works OK... I didn't have time to look for reason of this strange behaviour
- I've added -Duser.timezone=Europe/Warsaw to my JRE VM params in Eclipse
and it's working ok 

Thanx anyway

Wojtek




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Timezone

2005-09-18 Thread Wojciech Ciesielski
Hi there,

 

I have web-app deployed on JBoss and I am having some problems with date
objects :-/ I am trying to set login time to some bean and display this info
on page. In my LoginAction I do:

 

UserSession us = new UserSession(loggedUser);

TimeZone tz = TimeZone.getTimeZone("Europe/Warsaw");

GregorianCalendar cal = new GregorianCalendar(tz);

Timestamp loginTime = new Timestamp(cal.getTimeInMillis());

us.setLoginTime(loginTime);

request.getSession().setAttribute(USER_SESSION, us);

 

and on my JSP page:



 

But the problem is that it takes GMT timezone every time and I am in Poland
(CET +01). What should I do to get string with current time in my timezone ?

 

TIA 

Wojtek



RE: how to show data on jsp from bean

2005-09-17 Thread Wojciech Ciesielski
And one more thing - get yourself some good book/manual/tutorial on Struts.
There's plenty of them on o'reilly/amazon/direct connect/emule etc...

It's gonna be much easier ;-)




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: how to show data on jsp from bean

2005-09-17 Thread Wojciech Ciesielski
>  I am  new to struts and have a basic question regarding bean
> 
>  I am collecting some data(its a plain java bean) in an 'Action'
>  from database and want to show that data on a jsp page from where
>  it can be edited and submitted to some other 'Action' in the form
>  of 'ActionForm'
> 
>  I want to know what is the best approach of doing this

1. Create actions:
showMyForm.do (ShowMyFormAction class)
updateMyData.do (UpdateMyDataAction class)

2. Create ActionForm - for example MyForm class/form-name - and assign it to
updateMyData.do mapping in request scope

3. in ShowMyFormAction do something like this:
MyForm prefilledForm = new MyForm();
// ... set data from DB here
Request.setAttribute("MyForm","prefilledForm");

4. on page returned by ShowMyForm use struts HTML taglib:



...






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



A little bit OT: unicode escape editor

2005-09-15 Thread Wojciech Ciesielski
Hi there,

It's a bit off topic ;-) Does any of you know of some free/shareware editor
or eclipse plug-in allowing transforming Unicode text into ISO-8859-1
escaped strings?

TIA

Wojtek



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Newbie: html:link with action taken from bean

2005-09-14 Thread Wojciech Ciesielski
Thank you



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Newbie: html:link with action taken from bean

2005-09-14 Thread Wojciech Ciesielski
Hi there,

 

I am quite new to JSP and struts. So - as I suppose - quite "lame" question
;-)

In order to implement bread crumbs feature I have a collection bean,
containing simple PathElement objects in request scope. Each PathElement
contains two attributes:

-  titleKey (for resource key containing path element's title)

-  actionUri (with action to certain place in my app, like
"/doSomething.do")

 

And now I am trying to do something like this on my JSP page:

 











 

How can I force  tag to take action from bean?

 

THX



RE: Adding parameters to redirected forwards

2005-09-13 Thread Wojciech Ciesielski
THX :]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Adding parameters to redirected forwards

2005-09-13 Thread Wojciech Ciesielski
Hi there,

 

How can I add some parameters to redirected forwards? I have situation like
this: saveItem.do saves some object to the database and redirects to
showSavedItem.do, which is based on itemId in request parameter (passed
usually by URL). I want to make this as a redirect to prevent strange things
from happening when user refreshes page. But is there a way to add some
parameters to redirected forwards? Right not I am doing this by setting
session-scope attributes, but it's "messy" - I have to clean up session
afterwards.

 

TIA

 

Wojtek



Character encoding...

2005-09-11 Thread Wojciech Ciesielski
Hi,

 

I had problem with character encoding in my web application. I was trying to
display Polish characters using UTF-8 but data from forms was not getting in
proper format to the business layer. I managed to solve this by setting
filter  which does request.setCharacterEncoding(encoding); But the question
is: WHY it didn't work when I was using request.setCharacterEncoding() in
Action's execute() method?? 

 

Wojtek