Note that there are some explanatory texts on larger screens.

plurals
  1. POJAX-RS @PathParam How to pass a String with slashes, hyphens & equals too
    primarykey
    data
    text
    <p>I am new to JAX-RS and I am trying to use Jersey to build a simple RESTful Webservice.</p> <p>I have 2 questions. Please clarify these:</p> <ol> <li><p>I am trying to have my simple webservice like this URL <code>http://localhost:8080/SampleJersey/rest/inchi/InChIName</code></p> <p>The InChIName is a string like this <code>InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2- 5H,1H3,(H,11,12)</code>. How do I pass this as a <code>@PathParam</code>, I mean a normal String is working fine but here there are slashes,hyphens, and commas. How do I make it to ignore these. I tried putting it in quotes, but that didnt work. How should I do this?</p></li> <li><p>I need to pass that <code>InChI</code> to another webservice and that returns an XML as an output and I want to display that XML output as my Webservice's output. If I have <code>@Produces("application/xml")</code> will it work?</p></li> </ol> <p>This is my code:</p> <pre><code>@Path("/inchi") public class InChIto3D { @GET @Path("{inchiname}") @Produces("application/xml") public String get3DCoordinates(@PathParam("inchiname")String inchiName) { String ne=""; try{ URL eutilsurl = new URL( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?" + "db=pccompound&amp;term=%22"+inchiName+"%22[inchi]"); BufferedReader in = new BufferedReader( new InputStreamReader(eutilsurl.openStream())); String inputline; while ((inputline=in.readLine())!=null) ne=ne+inputline; }catch (MalformedURLException e1) { }catch (IOException e2){ } return ne; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload