I have a form like this:
<form id="form" method="post">
Name: <input name="name" />
E-Mail: <input name="email"/>
Comment: <textarea name="comment" cols="5" rows="10"></textarea>
<input type="submit" name="submit" value="submit"/>
</form>
for a commentary function for some developer blog. Therefore I need to insert the input into some database for some select queries later.
Now how do I tell the script which comments belong to which blog post?
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.
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.
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.
<cms:contentcheck ifexistsone="Header"><h2><cms:contentshow element="Header" /></h2></cms:contentcheck>
<p class="BlogEntry">
<cms:contentcheck ifexistsone="Text"><cms:contentshow element="Text" /></cms:contentcheck>
<cms:contentcheck ifexistsone="IntLink"><%@ include file="/system/modules/de.medienkonzepte.uform.templates/elements/internerlink.txt" %></cms:contentcheck>
</p>
<cms:contentcheck ifexistsone="Image">
<cms:contentloop element="Image">
<img style="padding:10px;" src="<cms:link><cms:contentshow element="ImageSrc" /></cms:link>" alt="<cms:contentshow element="Alt_Tag" />" />
</cms:contentloop>
</cms:contentcheck>
</cms:contentloop>
</cms:contentcheck>
<cms:contentcheck ifexistsone="Content/Text">
<c:set var="dateString"><cms:contentshow element="Date"/></c:set>
<%
java.util.Date date = new java.util.Date();
date.setTime(Long.parseLong(pageContext.getAttribute("dateString").toString()));
pageContext.setAttribute("date", date);
%>
<% // Author %>
<cms:contentcheck ifexistsone="Author"><p class="blogentry_author">Written by: <cms:contentshow element="Author"/> on <fmt:formatDate value="${date}" type="date" pattern="dd.MM.yyyy"/></p></cms:contentcheck>
</cms:contentcheck>
</div> <% // ende innercontent %>