Project

General

Profile

« Previous | Next » 

Revision 47

Added by Matt Jones over 24 years ago

improvements to MetaCatServlet engine, added html access pages for catalog query

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
9 9
import javax.servlet.http.HttpServlet;
10 10
import javax.servlet.http.HttpServletRequest;
11 11
import javax.servlet.http.HttpServletResponse;
12
import javax.servlet.http.HttpUtils;
12 13

  
13 14
/**
14 15
 * A metadata catalog server implemented as a Java Servlet
......
41 42
    throws ServletException, IOException {
42 43

  
43 44
    PrintWriter out;
44
    String query = "Value1";
45 45

  
46
    // Get the parameters from the form
47
    String querystring = request.getQueryString();
48
    Hashtable params = HttpUtils.parseQueryString(querystring);
49
    String[] query = (String[])params.get("query"); 
50

  
46 51
    // Run the query
47
    Hashtable nodelist = queryobj.findRootNodes(query);
52
    Hashtable nodelist = queryobj.findRootNodes(query[0]);
48 53

  
49 54
    // set content type and other response header fields first
50 55
    response.setContentType("text/xml");
......
56 61
    long nodeid;
57 62
    out.println("<?xml version=\"1.0\"?>\n");
58 63
    out.println("<resultset>\n");
64
    out.println("  <query>" + query[0] + "</query>");
59 65
    Enumeration rootlist = nodelist.keys(); 
60 66
    while (rootlist.hasMoreElements()) {
61 67
      nodeid = ((Long)rootlist.nextElement()).longValue();
......
66 72
    out.close();
67 73
  }
68 74

  
69
  public void doPost( HttpServletRequest req, HttpServletResponse res )
75
  public void doPost( HttpServletRequest request, HttpServletResponse response)
70 76
    throws ServletException, IOException {
77

  
78
    PrintWriter out;
79
    // set content type and other response header fields first
80
    response.setContentType("text/html");
81

  
82
    // then write the data of the response
83
    out = response.getWriter();
84
    out.println("POST detected");
85
    out.close();
71 86
  }
72 87

  
73 88
}
intro.html
1
<!--
2
  * contents.html
3
  *
4
  *      Authors: Matt Jones
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2000 April 5
9
  *      Version: 0.01
10
  *    File Info: '$Id$'
11
  * 
12
  * This is an HTML document for displaying examples of the use of 
13
  * Oracle XML tools
14
-->
15
<html>
16
<head>
17
<title>MetaCat</title>
18
</head>
19
<body bgcolor="white">
20
<b>MetaCat</b>
21
<p>
22
A simple query against a flexible metadata catalog.
23
</p>
24
</body>
25
</html>
0 26

  
contents.html
1
<!--
2
  * contents.html
3
  *
4
  *      Authors: Matt Jones
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2000 April 5
9
  *      Version: 0.01
10
  *    File Info: '$Id$'
11
  * 
12
  * This is an HTML document for displaying examples of the use of 
13
  * Oracle XML tools
14
-->
15
<html>
16
<head>
17
<title>MetaCat</title>
18
</head>
19
<body bgcolor="white">
20
<b>MetaCat Query</b>
21
<p>
22
Simple database query against MetaCat<br>
23
<form action="servlets/MetaCatServlet" target="right" method="GET">
24
  <input type="text" name="query" size="15">
25
  <input type="submit" value="Run query">
26
</form>
27
<p>
28
</body>
29
</html>
0 30

  
MetaCatServlet.java
9 9
import javax.servlet.http.HttpServlet;
10 10
import javax.servlet.http.HttpServletRequest;
11 11
import javax.servlet.http.HttpServletResponse;
12
import javax.servlet.http.HttpUtils;
12 13

  
13 14
/**
14 15
 * A metadata catalog server implemented as a Java Servlet
......
41 42
    throws ServletException, IOException {
42 43

  
43 44
    PrintWriter out;
44
    String query = "Value1";
45 45

  
46
    // Get the parameters from the form
47
    String querystring = request.getQueryString();
48
    Hashtable params = HttpUtils.parseQueryString(querystring);
49
    String[] query = (String[])params.get("query"); 
50

  
46 51
    // Run the query
47
    Hashtable nodelist = queryobj.findRootNodes(query);
52
    Hashtable nodelist = queryobj.findRootNodes(query[0]);
48 53

  
49 54
    // set content type and other response header fields first
50 55
    response.setContentType("text/xml");
......
56 61
    long nodeid;
57 62
    out.println("<?xml version=\"1.0\"?>\n");
58 63
    out.println("<resultset>\n");
64
    out.println("  <query>" + query[0] + "</query>");
59 65
    Enumeration rootlist = nodelist.keys(); 
60 66
    while (rootlist.hasMoreElements()) {
61 67
      nodeid = ((Long)rootlist.nextElement()).longValue();
......
66 72
    out.close();
67 73
  }
68 74

  
69
  public void doPost( HttpServletRequest req, HttpServletResponse res )
75
  public void doPost( HttpServletRequest request, HttpServletResponse response)
70 76
    throws ServletException, IOException {
77

  
78
    PrintWriter out;
79
    // set content type and other response header fields first
80
    response.setContentType("text/html");
81

  
82
    // then write the data of the response
83
    out = response.getWriter();
84
    out.println("POST detected");
85
    out.close();
71 86
  }
72 87

  
73 88
}
lib/contents.html
1
<!--
2
  * contents.html
3
  *
4
  *      Authors: Matt Jones
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2000 April 5
9
  *      Version: 0.01
10
  *    File Info: '$Id$'
11
  * 
12
  * This is an HTML document for displaying examples of the use of 
13
  * Oracle XML tools
14
-->
15
<html>
16
<head>
17
<title>MetaCat</title>
18
</head>
19
<body bgcolor="white">
20
<b>MetaCat Query</b>
21
<p>
22
Simple database query against MetaCat<br>
23
<form action="servlets/MetaCatServlet" target="right" method="GET">
24
  <input type="text" name="query" size="15">
25
  <input type="submit" value="Run query">
26
</form>
27
<p>
28
</body>
29
</html>
0 30

  
lib/index.html
1
<!--
2
  * index.html
3
  *
4
  *      Authors: Matt Jones
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2000 April 5
9
  *      Version: 0.01
10
  *    File Info: '$Id$'
11
  * 
12
  * This is an HTML document for displaying metadata catalog tools
13
-->
14
  <HTML>
15
  <HEAD>
16
  <TITLE>MetaCat</TITLE>
17
  </HEAD> 
18
  <FRAMESET ROWS="*" FRAMEBORDER=0 BORDER=0>
19

  
20
    <FRAMESET COLS="250,*"  FRAMEBORDER=0 BORDER=0>
21
    
22
    <FRAME SRC="contents.html" BORDER=0 NAME="left">
23

  
24
    <FRAME SRC="intro.html" BORDER=0 NAME="right">
25

  
26
    </FRAMESET>
27
  </FRAMESET>
0 28

  
index.html
1
<!--
2
  * index.html
3
  *
4
  *      Authors: Matt Jones
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2000 April 5
9
  *      Version: 0.01
10
  *    File Info: '$Id$'
11
  * 
12
  * This is an HTML document for displaying metadata catalog tools
13
-->
14
  <HTML>
15
  <HEAD>
16
  <TITLE>MetaCat</TITLE>
17
  </HEAD> 
18
  <FRAMESET ROWS="*" FRAMEBORDER=0 BORDER=0>
19

  
20
    <FRAMESET COLS="250,*"  FRAMEBORDER=0 BORDER=0>
21
    
22
    <FRAME SRC="contents.html" BORDER=0 NAME="left">
23

  
24
    <FRAME SRC="intro.html" BORDER=0 NAME="right">
25

  
26
    </FRAMESET>
27
  </FRAMESET>
0 28

  

Also available in: Unified diff