简体   繁体   中英

500 glassfish internal error while calling restful service with % sign in URL

I am getting HTTP 500 internal server error on glassfish 3.2.1 while putting % sign into URL as ledgerAccountNumber.

Sample url - https://domain:8181/services/generalLedgerAccountConfig/isLedgerAccountNumberInUse/200%?_=1398694030799

Restful service:

 @Path("/generalLedgerAccountConfig")
  public class ConfigGeneralLedgerAccount {

  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("isLedgerAccountNumberInUse/{ledgerAccountNumber}")
  public Response isLedgerAccountNumberInUse(@PathParam("ledgerAccountNumber") String ledgerAccountNumber) {
  ...
  }
 }

Any ideas why 500 http error is thrown?

% is not a valid character on its on in a URI path. It represents the start of an ASCII code for an unsafe character and anytime there is a '%' in the path it should be followed by two digits. Here it is followed by a "?".

If you want a literal % to be sent to your server you need to escape it as "%25". So your client is not properly encoding the URL. Whatever the client is, when it gets input from the user it has to properly encode that URL to get rid of illegal characters or escape legal ones.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM