• Post Reply Bookmark Topic Watch Topic
  • New Topic

build URL  RSS feed

 
Lydia Vaughan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm trying to build an URL that will look like below
http://host/path?a=?&b=?&c=? etc

Not all of the parameters are required, depending on the situation. So I may have a info but not b and c or I may have a and c but not b. I am building the URL to reference in a frame on a web page.

Any classes in Java that can do this? I've tried to use the GWT but receive an error message: java.lang.UnsatisfiedLinkError: com.google.gwt.http.client.URL.encode Impl(Ljava/lang/String;)Ljava/lang/String

Any ideas would be greatly appreciated.

Thanks in advance.
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rephrasing your requirement -- You want to generate URL String with some parameters. Number of parameters that needs to be added is decided at runtime.


This can be done using simple java (core java) concepts. give it a thought and reply with solution.

I do not want to post the code straight away as it will take all Java fun out of it ..

I will post the solution later on but give a thought from your side.

Please correct me if I have not understood the requirement correctly.

~ abhay




 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhay Agarwal wrote:I do not want to post the code straight away as it will take all Java fun out of it ..

I will post the solution later on but give a thought from your side.

Please LetThemDoTheirOwnHomework. You're right about not giving the code right now, but you also shouldn't give the code later on. Give hints, but let Lydia come to the solution herself.

Lydia, if you build the URL manually, take a look at URLEncoder and its encode(String s, String enc) method. That will allow you to use characters like &, ? and = inside the parameter names and values.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!