<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Core3: /Users/victor/git/Core3Mda/MMOCoreORB/src/server/web/servlets/Servlet.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Core3
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_075bb3ff235063c77951cd176d15a741.html">server</a></li><li class="navelem"><a class="el" href="dir_2d4538e89508371dea9075dca68a664a.html">web</a></li><li class="navelem"><a class="el" href="dir_ee0c6ca0f5bc196c5f1a76b7f898f9dd.html">servlets</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Servlet.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_servlet_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * WebComponent.cpp</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> *  Created on: May 31, 2011</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *      Author: kyle</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_servlet_8h.html">Servlet.h</a>&quot;</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;../mongoose/mongoose.h&quot;</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &quot;../WebServer.h&quot;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;</div>
<div class="line"><a name="l00012"></a><span class="lineno"><a class="code" href="class_servlet.html#a9f943525dee72507ec4b2395be0fa915">   12</a></span>&#160;<a class="code" href="class_servlet.html#a9f943525dee72507ec4b2395be0fa915">Servlet::Servlet</a>(String contxt) {</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;        <a class="code" href="class_servlet.html#a1ddee50114a33f831f9200f220cd8bef">context</a> = contxt;</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;        setLogging(<span class="keyword">true</span>);</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;        setLoggingName(<span class="stringliteral">&quot;Webserver:&quot;</span> + <a class="code" href="class_servlet.html#a1ddee50114a33f831f9200f220cd8bef">context</a>);</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;}</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="code" href="class_servlet.html#aa676a50a43b51d0c4e12319e6e1dc028">   20</a></span>&#160;<a class="code" href="class_servlet.html#aa676a50a43b51d0c4e12319e6e1dc028">Servlet::~Servlet</a>() {</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;        <span class="comment">// TODO Auto-generated destructor stub</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;}</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="code" href="class_servlet.html#ae58f1423220c8b2c4d7efeacb1fc7883">   24</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_servlet.html#ae58f1423220c8b2c4d7efeacb1fc7883">Servlet::handleRequest</a>(<span class="keyword">struct</span> <a class="code" href="structmg__connection.html">mg_connection</a> *conn, <a class="code" href="classserver_1_1web_1_1_http_request.html">HttpRequest</a>* request, <a class="code" href="classserver_1_1web_1_1_http_response.html">HttpResponse</a>* response) {</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;        <span class="keywordflow">try</span> {</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;                <span class="keywordflow">if</span>(request-&gt;<a class="code" href="classserver_1_1web_1_1_http_request.html#a72a1f0a5d1bebe527277e552d52e438b">getRequestMethod</a>() == <span class="stringliteral">&quot;GET&quot;</span>) {</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;                        <a class="code" href="class_servlet.html#aeec6ac39960cfe1a5f4e4db13f3b1622">handleGet</a>(request, response);</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;                } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (request-&gt;<a class="code" href="classserver_1_1web_1_1_http_request.html#a72a1f0a5d1bebe527277e552d52e438b">getRequestMethod</a>() == <span class="stringliteral">&quot;POST&quot;</span>) {</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;                        <a class="code" href="class_servlet.html#ac65c8f3a7a159cee729ad1e7ca94e589">handlePost</a>(request, response);</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;                } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;                        response-&gt;<a class="code" href="classserver_1_1web_1_1_http_response.html#affd0d12bf5816bdb5ead00578773535c">println</a>(<span class="stringliteral">&quot;Webserver doesn&#39;t handle request type:&quot;</span> + request-&gt;<a class="code" href="classserver_1_1web_1_1_http_request.html#a72a1f0a5d1bebe527277e552d52e438b">getRequestMethod</a>());</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;                        error(<span class="stringliteral">&quot;Webserver doesn&#39;t handle request type:&quot;</span> + request-&gt;<a class="code" href="classserver_1_1web_1_1_http_request.html#a72a1f0a5d1bebe527277e552d52e438b">getRequestMethod</a>());</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;                }</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        } <span class="keywordflow">catch</span>(Exception&amp; e) {</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;                error(<span class="stringliteral">&quot;Unhandled Exception:&quot;</span> + e.getMessage());</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;        }</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;        <a class="code" href="class_servlet.html#a8ff3c44e842270d163826bd184976ca2">outputResponse</a>(conn, response);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;}</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;</div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="code" href="class_servlet.html#a8ff3c44e842270d163826bd184976ca2">   48</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_servlet.html#a8ff3c44e842270d163826bd184976ca2">Servlet::outputResponse</a>(<span class="keyword">struct</span> <a class="code" href="structmg__connection.html">mg_connection</a> *conn, <a class="code" href="classserver_1_1web_1_1_http_response.html">HttpResponse</a>* response) {</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        <a class="code" href="mongoose_8c.html#a2dca037be3c41853a3dd0d6c338b9cf4">mg_printf</a>(conn, response-&gt;<a class="code" href="classserver_1_1web_1_1_http_response.html#ae5e4d402f6a1043df80d5c51346b8d36">generatePage</a>().toCharArray());</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Tue Oct 15 2013 17:28:33 for Core3 by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.3.1
</small></address>
</body>
</html>
