Jump to content

Url Java Encoding


Recommended Posts

Hello Caspio Forum!

 

First post here.

 

One of my links include the following instruction to pass a variable: 

 

<a id="mylink"  href="culex.ca/client-portal/administration-login/forms-and-reports/adult-and-species-id-form&cbResetParam=1&TPSampleID=" onclick="window.open(this.href, 'mywin','left=20,top=20,width=1100,height=800,resizable=0'); return false;"target="_blank">Click here to Open Species Form</a>

 

Note: I removed the "http://www" here so the link is displayed complete. 

 

Unfortunately the instructions in the URL get encoded like this in my webpage: 

 

"%26cbResetParam%3D1%26TPSampleID%3D"

 

I tried using URLEncoder like this:

 

<a id="mylink"  href="http://www.culex.ca/client-portal/administration-login/forms-and-reports/adult-and-species-id-form&cbResetParam=1&TPSampleID=" + URLEncoder.encode("&cbResetParam=1&TPSampleID=", "ISO-8859-1");

onclick="window.open(this.href, 'mywin','left=20,top=20,width=1100,height=800,resizable=0'); return false;"target="_blank">Click here to Open Species Form</a>

 

but the problem remains the same.

 

Any ideas how to fix this one?

 

Thank you

 

D

Link to comment
Share on other sites

Hi MayMusic,

 

Sorry for taking so long to thank you for your answer. The crazy days of holidays!

 

Unfortunately I still have the same problem (i.e., the link encodes the url improperly). Do you have any experience working with URLEncoder?

 

Thank you and Happy holidays!

 

D

Link to comment
Share on other sites

I dont know a whole lot about encoding URLs but I did recently work through my own issue using javascript's encodeURI and and looking at the encoded url that is correct.  

 

"%26cbResetParam%3D1%26TPSampleID%3D"

 

%26 = "&"

%3D = "="

 

It looks like it is encoding it correctly.  

If you want it to look like this "culex.ca/client-portal/administration-login/forms-and-reports/adult-and-species-id-form&cbResetParam=1&TPSampleID=" when it gets to your page, you may have to use the decode function which should replace all the %26 and %3D back to & and =.  This is javascript based though and it looks like "URLEncoder.encode" is part of Java, but there should be a similar answer for straight Java. You may just receive the encoded url and use code on the website to decode it and pull the passed parameters that way.

 

 

http://www.w3schools.com/jsref/jsref_decodeuri.asp

http://www.w3schools.com/tags/ref_urlencode.asp

Link to comment
Share on other sites

Hi NarayanJr,

 

Try this:

<a id="mylink"  href="http://culex.ca/client-portal/administration-login/forms-and-reports/adult-and-species-id-form?cbResetParam=1&TPSampleID=" onclick="javascript:window.open(this.href, 'mywin','left=20,top=20,width=1100,height=800,resizable=0'); return false;"target="_blank">Click here to Open Species Form</a>

Is this what you need?

Link to comment
Share on other sites

Hello MayMusic, NarayanJr and ShWolf,

 

Thank you for all your suggestions. You were right. The problem was the "&". I figured it thanks to my account manager. I just changed this:

 

<a id="mylink"  href="http://culex.ca/client-portal/test-2/&cbResetParam=1&TPSampleID=" onclick="window.open(this.href, 'mywin', 'left=20,top=20,width=1100,height=800,resizable=0'); return false;"target="_blank">Click here to Open Species Form</a>

 

to

 

<a id="mylink"  href="http://culex.ca/client-portal/test-2/?cbResetParam=1&TPSampleID=" onclick="window.open(this.href, 'mywin', 'left=20,top=20,width=1100,height=800,resizable=0'); return false;"target="_blank">Click here to Open Species Form</a>

 

cheers

 

Culex

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...