You could definitely do that, too. If you just create a new Url(yourstringhere) it 
will raise that exception if it's malformed, so it won't waste time creating a 
connection to a malformed url. I guess that's probably a better solution than the 
regex one, too, because it's simpler.

-- 
If education is too expensive, try ignorance.


On Tue, 15 Jul 2003 07:03:59 -0700 (PDT)
"Prashanth.S" <[EMAIL PROTECTED]> wrote:

> Hi all,
> How abt throwing MalformedURLException in the service method inside action class??
> Than no need to do validation in action form??
> Is it correct??
> Help??
> Thanks
> Prashanth
> 
> Dichotomy <[EMAIL PROTECTED]> wrote:
> Steps:
> 
> 1) Use a regular expression to check that the url fits the pattern you are looking 
> for (here's a good tutorial on regexes: 
> http://www.zvon.org/other/PerlTutorial/Output/index.html). You can do this directly 
> with the validator framework if you're using it, or later from the action.
> 2) Open a java.io or java.nio connection to that url to check that it is valid. Look 
> into File and/or InputStream for more info on how to do this.
> 
> You should never put any logic in the form bean itself (it should remain a plain 
> dumb form bean). Put this code in a library and make a call to it from your action.
> 
> -- 
> If education is too expensive, try ignorance.
> 
> 
> On Tue, 15 Jul 2003 06:36:14 -0700 (PDT)
> "Prashanth.S" wrote:
> 
> > Hi all,
> > I need to upload a resource present at a particular location by making user enter 
> > a valid URL...How can i do URL name validation using struts???Is there anything to 
> > do so??Do i need to do this in action form or action class??[what User entered is 
> > a valid url i.e,both name as well as resource present at that url)
> > Thanks in advance
> > Prashanth
> > 
> > 
> > 
> > ---------------------------------
> > Do you Yahoo!?
> > SBC Yahoo! DSL - Now only $29.95 per month!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!

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

Reply via email to