Developer Central
Developer Central Links
My Right to Know (MyRTK) Code Documentation
- Download Code (.zip, 2.8MB) | Open Source Agreement (.doc, 4pp, 21K)
- Overview
- Where does my data come from?
- How is the data displayed?
- Discussion of sample code in chems.jsp
- REST Service Call
- How are maps displayed?
- Bi-Lingual support in MyRTK
- How to get started using MyRTK
MyRTK is an EPA Web application designed for mobile devices. MyRTK maps, for any location or address, nearby facilities that report to the Toxics Release Inventory (TRI), as well as large permit holders in EPA's Air, Water or Hazardous Waste programs that are expected to produce, manage, or release TRI-reportable chemicals. MyRTK is also compatible with most Web-enabled mobile phone browsers and most desktop browsers.
Where does my data come from?
MyRTK makes use of data from the following EPA databases: Envirofacts, Enforcement & Compliance History Online (ECHO), and TRI datasets. To obtain data for display within the application MyRTK makes use of the Envirofacts RESTful Web Services. These services are consumed by MyRTK to capture and display the data that you see within the application. All of the REST Web Service Application Programming Interfaces (API) are listed in the file AppProperties.property located under the "WEB-INF" folder. Please refer to the Envirofacts RESTful Web Services API documentation for further information on these services, and how you can make use of them within your application.
Each JSP has been dedicated to render data that comes from a table in the database.
The table below gives the list of JSP and the data tables.
| Page Name | Resource Table |
|---|---|
| Search.jsp | None |
| Map.jsp | MYRTK_TBL_UNIQUELOCATIONS via location.jsp |
| List.jsp | MYRTK_TBL_UNIQUELOCATIONS MYRTK_TBL_FRSSOURCES MYRTK_TBLTRI_FACILITY MYRTK_TBLNONTRI_FACILITY |
| Report.jsp | MYRTK_TBLTRI_CHEMICALS MYRTK_TBL_UNIQUELOCATIONS MYRTK_TBLTRIALL_COMPL MYRTK_TBLNONTRI_COMPL MYRTK_TBL_CHEMICALPROPERTIES |
| Chems.jsp | MYRTK_TBL_CHEMICALPROPERTIES |
Discussion of sample code in chems.jsp
- View the chemical page for Lead by navigating to the facility report for AMITRON CORP (Toxics Release Inventory ID = 60007MTRNC2001L)
- Click on “LEAD” listed under ON SITE RELEASES BY CHEMICAL
The "chems.jsp" page displays the chemical information for Lead.

The REST Web Service call behind the page is:
http://iaspub.epa.gov/enviro/efservice/MYRTK_TBL_CHEMICALPROPERTIES/CAS/<CAS VALUE>/JSON
The value for the parameter Chemical Abstract Service (CAS) is set within the "chem.jsp" page, so that the service call is completed and invoked.
See sample source code from the "chems.jsp" page:
String chemuri= property.getProperty("chemuri");
String uri = chemuri+CAS+"/JSON";
URL url = new URL(uri);
HttpURLConnection connection =
(HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/json");
String id1 = "";
InputStream is = connection.getInputStream();
String jsonTxt = IOUtils.toString( is );
JSONArray json = (JSONArray) JSONSerializer.toJSON( jsonTxt );
connection.disconnect();
int i = 0;
JSONObject rs = json.getJSONObject(i);
str_ID=rs.getString("ID");
str_CHEMICAL=rs.getString("CHEMICAL");
The property “chemuri”, which stores the REST Web Service call , is retrieved from AppProperties.property file.
The string CAS which is sent as a request parameter from the report page, is being used to complete the REST Web Service call.
A JSON Object is requested. The returned JSON Object is serialized into a JSONArray. The JSONObject (rs) retrieved from the array has the data is the array.
To get the Chemical Name , the method rs.getString("CHEMICAL") is invoked.
MyRTK uses Google Maps API v2 to display the map and plot facilities on the map.
The following line implies that Google Maps is used and the available functions are within the API.
The function load(), sets the desired map options and invokes the map
var center = findCenter();
var zoom = findZoom();
// Set map options
var myOptions = {
center: center,
zoom: zoom,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControlOptions:
{style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
}
// Define the map
map = new google.maps.Map(document.getElementById("trimap"), myOptions);
….
….
The function populateMap() gets the map bounding parameters and makes the request to locations.jsp
modalState = 0;
// Get our boundaries
var swlat = map.getBounds().getSouthWest().lat();
var swlng = map.getBounds().getSouthWest().lng();
var nelat = map.getBounds().getNorthEast().lat();
var nelng = map.getBounds().getNorthEast().lng();
// Set up our XML request
var passToList = "swlat="+swlat+"&swlng="+swlng+"&nelat="+nelat+"&nelng="+nelng;
// Call location.jsp
var searchUrl = 'locations.jsp?'+passToList;
del_cookie('bounds');
setCookie('bounds',passToList,1);
// Make our XML request
downloadUrl(searchUrl, function(data) {
var xml = parseXml(data);
………………………..
…………………..
- The "locations.jsp" page makes the REST Web Service calls to MYRTK_TBL_UNIQUELOCATIONS with the required parameters, and returns the parsed data back to map.jsp.
- map.jsp receives this data,creates markers, and displays the facilities on the map.

MyRTK application can be accessed in two languages: English and Spanish. The information on every JSP comes either from EngLang.property or SpnLang.property files.
The radio button choice at the top of every JSP lets the user choose to view the page in English or Spanish.

The "setsessn.jsp" page stores the user’s choice in the session.
Sample code from setsessn.jsp:
if(lparm != null)
{
session.setAttribute("langparm1", lparm.trim());
}
………….
The "langpage.jsp" page reads the session and loads the correct property file .
Sample code from langpage.jsp:
<%@ include file="setsessn.jsp" %>
………….
String langparm1 = (String)session.getAttribute("langparm1");
String langparm = "eng";
String filenm = "";
if(langparm1.trim().equalsIgnoreCase("eng"))
{ filenm = "/WEB-INF/EngLang.property"; }
else
{ langparm1 = "spn"; filenm = "/WEB-INF/SpnLang.property"; }
java.util.Properties langproperty = null;
ServletContext langcontext = getServletContext();
InputStream langinputStream =langcontext.getResourceAsStream(filenm);
langproperty =new Properties();
langproperty.load(langinputStream );
String back1 = langproperty.getProperty("BACK");
String map = langproperty.getProperty("MAP");
…………………
…………………….
The Key-Value pairs are retrieved and used to display the text in the page.
All display pages in the application include the "langpage.jsp" page by using the code below:
Below is the Information page, in English and in Spanish:


How to get started using MyRTK
MyRTK is a Java application that that is hosted on a Java application server. The application has currently been tested using the Java application server Apache Tomcat Versions v6.0.20 and above. To run the application you will need to deploy the MyRTK application to a Java application server. Please refer to your Java application server’s manual for information on how to perform the deployment.
Upon successful deployment, the MyRTK application will be available at the following URL: http://host:port/myRTK/index.jsp. The “host” and “port” information are specific to the deployment environment, so please modify them accordingly. For information on the “host” and “port”, please refer to your Java application server’s manual.


