title: OpenCMS: How to use variables in JSP/Javascript/Java?
body: <p>I have a form like this:</p>
  
  <pre><code>&lt;form id="form" method="post"&gt;
      Name: &lt;input name="name" /&gt;
      E-Mail: &lt;input name="email"/&gt;
      Comment: &lt;textarea name="comment" cols="5" rows="10"&gt;&lt;/textarea&gt;
      &lt;input type="submit" name="submit" value="submit"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>for a commentary function for some developer blog. Therefore I need to insert the input into some database for some select queries later. </p>
  
  <p>Now how do I tell the script which comments belong to which blog post? </p>
  
  <p>My idea would be to get the name of the file or the title of the entry or something and put it into the query I'm creating. And I might manage to find out how to get the filename in OpenCMS as well - that's about five minutes of searching, if any - but what I don't know is how I get the OpenCMS variable into my Java part of the file, where I set up the actual query/queries.</p>
  
  <p>I searched for that earlier already, some weeks ago, but I managed to find a way to avoid this then. Now though I can't think of a way of avoidance either, so I'm hoping that someone knows how to get this done properly.</p>
  
  <p>In case you need this, here's the code for the actual blog entries so far, I'm going to append the commentary function (being an element) underneath the author information then.</p>
  
  <p>
                  </p>
  
  <pre><code>                &lt;cms:contentcheck ifexistsone="Header"&gt;&lt;h2&gt;&lt;cms:contentshow element="Header" /&gt;&lt;/h2&gt;&lt;/cms:contentcheck&gt;
                  &lt;p class="BlogEntry"&gt;
                  &lt;cms:contentcheck ifexistsone="Text"&gt;&lt;cms:contentshow element="Text" /&gt;&lt;/cms:contentcheck&gt;  
                  &lt;cms:contentcheck ifexistsone="IntLink"&gt;&lt;%@ include file="/system/modules/de.medienkonzepte.uform.templates/elements/internerlink.txt" %&gt;&lt;/cms:contentcheck&gt;
                  &lt;/p&gt;
                  &lt;cms:contentcheck ifexistsone="Image"&gt;
                      &lt;cms:contentloop element="Image"&gt;
                          &lt;img style="padding:10px;" src="&lt;cms:link&gt;&lt;cms:contentshow element="ImageSrc" /&gt;&lt;/cms:link&gt;" alt="&lt;cms:contentshow element="Alt_Tag" /&gt;" /&gt;
                      &lt;/cms:contentloop&gt;
                  &lt;/cms:contentcheck&gt;
  
              &lt;/cms:contentloop&gt;
          &lt;/cms:contentcheck&gt;
                   &lt;cms:contentcheck ifexistsone="Content/Text"&gt;
  
          &lt;c:set var="dateString"&gt;&lt;cms:contentshow element="Date"/&gt;&lt;/c:set&gt;
          &lt;% 
           java.util.Date date = new java.util.Date(); 
  
           date.setTime(Long.parseLong(pageContext.getAttribute("dateString").toString())); 
           pageContext.setAttribute("date", date); 
          %&gt;                  
  
                  &lt;% // Author %&gt;
                  &lt;cms:contentcheck ifexistsone="Author"&gt;&lt;p class="blogentry_author"&gt;Written by: &lt;cms:contentshow element="Author"/&gt; on &lt;fmt:formatDate value="${date}" type="date" pattern="dd.MM.yyyy"/&gt;&lt;/p&gt;&lt;/cms:contentcheck&gt;
  
          &lt;/cms:contentcheck&gt; 
      &lt;/div&gt; &lt;% // ende innercontent %&gt;
  </code></pre>