User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 397,591 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,863 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 11480 | Replies: 12
Reply
Join Date: Mar 2005
Posts: 13
Reputation: grajeshmsc is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
grajeshmsc grajeshmsc is offline Offline
Newbie Poster

URL Validation

  #1  
Jul 1st, 2005
Hi All
I want to validate the format of file path using struts.That is if the user gives c/:Test.txt instead of c:\Test.txt.PLz Help.
Thank you
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Posts: 17
Reputation: techy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
techy techy is offline Offline
Newbie Poster

Re: URL Validation

  #2  
Jul 12th, 2005
Just use StringTokenizer and look for the /. If found replace it with the one you want.

Regards,
Techy
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,660
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 192
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: URL Validation

  #3  
Jul 13th, 2005
There's nothing wrong with either path...
And what about other operating systems?
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: URL Validation

  #4  
Jul 13th, 2005
why would you allow the user to enter the path anyway?(not that it's a bad thing) Why can't you use a file browser?
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,660
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 192
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: URL Validation

  #5  
Jul 14th, 2005
You should always allow manual entry as well.
It works a LOT faster if the user knows what he wants to enter.

But I'd not validate paths at all. The client is solely responsible for that, all the server should do is gracefully handle the situation in which the file doesn't exist.

And NEVER let the user enter a path and/or filename existing on the server and have the server do something with that file. That's a massive breach of security.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: URL Validation

  #6  
Jul 14th, 2005
Maybe I don't understand the context. Wouldn't it be better in many ways to have a browse button(say the user wants to upload something) even if he/she does know the URL?
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,660
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 192
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: URL Validation

  #7  
Jul 15th, 2005
yes, having a button as an optional way to fill the file location is fine.
But you should not require the use of that button by not providing an input field for manual entry.
Pressing a button, launching a popup, filling the location in that, clicking another button, that's 4 steps to fill the file location.
Just filling it directly is a single step, far faster.

Maybe not that important on a hobby site where people may use it once a month or so, but on a professional intranet application where it's used by many people many times a day it becomes first a major annoyance and then reason for the application to require changing to improve performance.

Also, one should never rely solely on clientside validation (which forcing the user to select an option from a popup dialog effectively is), as someone will come who circumvents that in some way.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: URL Validation

  #8  
Jul 15th, 2005
Okay, that makes more sense. So basicly it comes down to the popups "blowing up" in the users face, which I've always tried to avoid. I guess you could have both validations as an option to suit both sides of things. Thanks for the help.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: URL Validation

  #9  
Jul 15th, 2005
I'm a little confused here. Lets say this is an upload page were the user enters the path or clicks the browse button, whichever he/she prefers. How exactly do you get that file off their computer since there is so many restrictions with java?
Reply With Quote  
Join Date: Mar 2005
Posts: 13
Reputation: grajeshmsc is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
grajeshmsc grajeshmsc is offline Offline
Newbie Poster

Re: URL Validation

  #10  
Jul 17th, 2005
HI
Thankz for your replies. Actually we r developing an Intranet application in which the user should specify the resource files and the result files folder which is in the server.So i need a validation to validate the entered file path is correct and available. Now i got another solution.tht is
/* to hold the file path */
StringBuffer localSBFilePath = new StringBuffer( File.separator);
/* to hold the boolean value for long term files folder exists */
boolean localIsLongTermFolderExists = false;
/* to hold the long term files folder */
String localLongTermFilesFolder = null;
/* to hold the FILE */
File localFile = null;
/* get the long term files folder */
localLongTermFilesFolder = PrimaryServerAdminPKForm.getPServerStorage();// Here PrimaryServerAdminPKForm is an form bean using Struts.
/* append the file path*/
localSBFilePath.append(localLongTermFilesFolder);
localFile = new File(localSBFilePath.toString());
/* check the folder exists in the given path */
localIsLongTermFolderExists = localFile.isDirectory();
/* if not throw exception */
if (!(localIsLongTermFolderExists))
{
throw new AppsCustomException("error.PrimaryServerAdminPKForm.primaryserver.FileNotFound");
}


Thankz for all
cheers mite
Rajesh G.


Originally Posted by server_crash
I'm a little confused here. Lets say this is an upload page were the user enters the path or clicks the browse button, whichever he/she prefers. How exactly do you get that file off their computer since there is so many restrictions with java?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JSP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 6:04 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC