Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting hostname of the client that is calling my JAX-RS rest webservice
    primarykey
    data
    text
    <p>I have developed my rest service in JAX-RS jersey. I have deployed in the Tomcat 7.0. Now I am exposing my web service url to third party client. I want to put validation mechanism that include getting host name i.e. the client host name that is using my service. I would like to match with our database entered host name. </p> <p>Problems - How to get the Host Name of the client.</p> <p>Thanks</p> <p>Here are my web.xml -</p> <p></p> <pre><code>&lt;servlet-name&gt;ServletAdaptor&lt;/servlet-name&gt; &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;ServletAdaptor&lt;/servlet-name&gt; &lt;url-pattern&gt;/intellixservices/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;filter&gt; &lt;filter-name&gt;secureRESTFilter&lt;/filter-name&gt; &lt;filter-class&gt;com.astroved.intellix.security.SecurityFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;secureRESTFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/intellixservices/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre> <p>Now I am creating a SecurityFilter class implementing Filter. inside doFilter() method -</p> <pre><code>@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) req; HttpServletResponse httpRes = (HttpServletResponse)res; String url = "http://localhost:8888/IntellixWebApi/intellixservices/dnareport"; System.out.println("In security filter"); req.getRequestDispatcher(url).forward(req, res); chain.doFilter(httpReq, httpRes); } </code></pre> <p>But it is not forwarding to the next url. In Resource class; it is returning xml/json type. </p> <p>Please help.</p>
    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