*
The moose likes Java in General and the fly likes Which is the best approach for URL creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Which is the best approach for URL creation" Watch "Which is the best approach for URL creation" New topic
Author

Which is the best approach for URL creation

zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi,

I need to understand the best approach to form a URL. Right now I have two approaches,



or

I can use a pattern to achieve the same.


Can you tell me which is the best approach to follow? And it would be really helpful to know more approaches to this URL generation.


Thanks in Advance...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't know what you mean by a "pattern", but in any case neither of them is the best approach (note that your first approach puts too many slashes between the host and path parts, for example). Here's the best approach:
zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi Paul, Thanks for your suggestion.

I don't know what you mean by a "pattern"


I was actually referring to using Message Formatter (java.text) for this.

I have one problem with your suggestion. The code you mentioned above will be effective if it runs only a few times. But in my case, it runs more than 100 times per minute; and when each time the code runs, it generates different jsp names (This is more of a business logic - so do not worry about why different names for a jsp ).

So, creating URL object for each jsp name does not seems to be a better approach. Please let me know if you have any other thought?


Regards,
Zahid
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which is the best approach for URL creation
 
Similar Threads
instantiate ActionForward objects
Binary Files
get pixels of a jPanel
Controller Servlet
Spring AOP vs Annotation based Tx Management