Quantcast

Easy way to get the service root in a JSP or ReportDisplayer?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Easy way to get the service root in a JSP or ReportDisplayer?

Sam Hokin-3
Hiya, devs. I'm coming up empty on a method using IM classes to get the service root from within a ReportDisplayer (where I don't
need it but can pass it on to the calling JSP) or a JSP on its own. Right now I'm using:

String serviceRoot =
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getServletContext().getContextPath()+"/service";

Which works (if the service is on the same Tomcat context), but isn't quite as nice as SomeIntermineClass.getServiceRootUrl().

The only place such a method exists, that I can find, is Service.getRootUrl(), but I can't figure out how to instantiate a Service
object within a JSP or ReportDisplayer.

I also see the interface method org.intermine.webservice.client.core.Request.getServiceUrl(), but I don't see how to get at that,
either. The request object in my JSPs is org.apache.catalina.core.ApplicationHttpRequest.

Thanks for tips!
Sam
_______________________________________________
dev mailing list
[hidden email]
https://lists.intermine.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Easy way to get the service root in a JSP or ReportDisplayer?

Yo Yehudi-2
Hi Sam,

I'm not aware of any such method, but if others are they can feel free to override me :) 

A couple of options that occur to me: 

1: it looks like imtables uses a mix of the current window url and reading from a properties file, if javascript's your preferred way:

var root = window.location.origin + "/${WEB_PROPERTIES['webapp.path']}";



2: You could also just add webapp.service.url to the relevant properties file and output it in the jsp like so: 

<div id="kittens">
webapp.service.url: ${WEB_PROPERTIES['webapp.service.url']}
</div>

This results in output like this in a browser: 

<div id="kittens">
</div>


Hope that helps and let me know if it doesn't! 

Yo



On 1 December 2016 at 17:37, Sam Hokin <[hidden email]> wrote:
Hiya, devs. I'm coming up empty on a method using IM classes to get the service root from within a ReportDisplayer (where I don't need it but can pass it on to the calling JSP) or a JSP on its own. Right now I'm using:

String serviceRoot = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getServletContext().getContextPath()+"/service";

Which works (if the service is on the same Tomcat context), but isn't quite as nice as SomeIntermineClass.getServiceRootUrl().

The only place such a method exists, that I can find, is Service.getRootUrl(), but I can't figure out how to instantiate a Service object within a JSP or ReportDisplayer.

I also see the interface method org.intermine.webservice.client.core.Request.getServiceUrl(), but I don't see how to get at that, either. The request object in my JSPs is org.apache.catalina.core.ApplicationHttpRequest.

Thanks for tips!
Sam
_______________________________________________
dev mailing list
[hidden email]
https://lists.intermine.org/mailman/listinfo/dev


_______________________________________________
dev mailing list
[hidden email]
https://lists.intermine.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Easy way to get the service root in a JSP or ReportDisplayer?

Sam Hokin-3
Thanks, Yo. The thing is I'm writing my mines on a dev server and then promoting them to the production server with no change in
web.properties. So I always look for automated ways to figure things out that are server independent. So I think I'll stick with my
Java calls, since they'll work anywhere with no web.properties dependence. No biggy, just thought there might be some hidden method
somewhere in the IM forest.

On 12/08/2016 04:29 AM, Yo Yehudi wrote:

> Hi Sam,
>
> I'm not aware of any such method, but if others are they can feel free to override me :)
>
> A couple of options that occur to me:
>
> 1: it looks like imtables uses a mix of the current window url and reading from a properties file, if javascript's your preferred way:
>
> var root = window.location.origin + "/${WEB_PROPERTIES['webapp.path']}";
>
> example where this is done:
> https://github.com/intermine/intermine/blob/3328168aa750f1175d9e7c6bb2a516455cfc9bd1/intermine/webapp/main/resources/webapp/layout.jsp#L115
> <https://github.com/intermine/intermine/blob/3328168aa750f1175d9e7c6bb2a516455cfc9bd1/intermine/webapp/main/resources/webapp/layout.jsp#L115>
>
>
> 2: You could also just add webapp.service.url to the relevant properties file and output it in the jsp like so:
>
> <div id="kittens">
> webapp.service.url: ${WEB_PROPERTIES['webapp.service.url']}
> </div>
>
> This results in output like this in a browser:
>
> <div id="kittens">
> webapp.service.url: http://mycomputername:8080/flymine/service
> </div>
>
> more on property files: http://intermine.readthedocs.io/en/latest/webapp/properties/intermine-properties/
> <http://intermine.readthedocs.io/en/latest/webapp/properties/intermine-properties/>
>
> Hope that helps and let me know if it doesn't!
>
> Yo
>
>
>
> On 1 December 2016 at 17:37, Sam Hokin <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hiya, devs. I'm coming up empty on a method using IM classes to get the service root from within a ReportDisplayer (where I
>     don't need it but can pass it on to the calling JSP) or a JSP on its own. Right now I'm using:
>
>     String serviceRoot =
>     request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getServletContext().getContextPath()+"/service";
>
>     Which works (if the service is on the same Tomcat context), but isn't quite as nice as SomeIntermineClass.getServiceRootUrl().
>
>     The only place such a method exists, that I can find, is Service.getRootUrl(), but I can't figure out how to instantiate a
>     Service object within a JSP or ReportDisplayer.
>
>     I also see the interface method org.intermine.webservice.client.core.Request.getServiceUrl(), but I don't see how to get at
>     that, either. The request object in my JSPs is org.apache.catalina.core.ApplicationHttpRequest.
>
>     Thanks for tips!
>     Sam
>     _______________________________________________
>     dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.intermine.org/mailman/listinfo/dev <https://lists.intermine.org/mailman/listinfo/dev>
>
>
_______________________________________________
dev mailing list
[hidden email]
https://lists.intermine.org/mailman/listinfo/dev
Loading...