I wrote this code in java 7 and it works without problems. I'm now trying to use java 6, and it's getting strange : the request object does not have any visible parameter, so I can't access the info I send with the form.
Here is the code :
<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Thesaurus Builder</title>
<link type="text/css" rel="stylesheet" href="<c:url value="/form.css"/>" />
</head>
<body>
<form action="<c:url value='/' />" method="post" enctype="multipart/form-data"> <!-- accept-charset="UTF-8" -->
<fieldset>
<legend>Analyse de texte</legend>
<label for="file">Fichier à analyser</label>
<textarea rows="7" cols="100" name="file" id="file" ></textarea>
<br />
<br />
<label for="encoding">Encodage</label>
<input type="text" id="encoding" name="encoding" value="UTF-8" />
<br />
<br />
<label for="skos">Choississez un thesaurus</label>
<c:if test="${empty listThesaurus}">
<input type="text" id="skos" name="skos" value="No thesaurus avalaible" disabled = "disabled"/>
</c:if>
<c:if test="${not empty listThesaurus}">
<select id="skos" name="skos" >
<c:forEach var="item" items="${listThesaurus}">
<option value= "<c:out value="${item.key}/${item.value}" />" ><c:out value="${item.key} - ${item.value}" /></option>
</c:forEach>
</select>
</c:if>
<br />
<br />
<label for="model">Choississez un model (temp)</label>
<c:if test="${empty listModel}">
<input type="text" id="encoding" name="encoding" value="No model avalaible" disabled = "disabled"/>
</c:if>
<c:if test="${not empty listModel}">
<select id="model" name="model" >
<c:forEach var="item" items="${listModel}">
<option value= "<c:out value="${item.key}/${item.value}}" />" ><c:out value="${item.key} - ${item.value}" /></option>
</c:forEach>
<c:if test="${empty listModel}"></c:if>
</select>
</c:if>
<br />
<br />
<br />
<label for="debug">Mode Debug</label>
<input type="checkbox" id="debug" name="debug"/>
<br />
<br />
<input type="submit" value="Envoyer" class="sansLabel" />
<br />
</fieldset>
</form>
<c:if test="${not empty param.debug }">
<c:if test="${not empty debug }">
<p class="debug"><c:forEach items="${debug}" var="e">${e}<br/></c:forEach></p>
</c:if>
</c:if>
<c:if test="${not empty errors}">
<p class="error"><c:forEach items="${errors}" var="e">${e}<br/></c:forEach></p>
</c:if>
<c:if test="${not empty tags}">
<h3>Résultat Etude stockastique :</h3>
<div id="tagCLoud">
<h4>Tag Cloud </h4>
<c:forEach items="${tags}" var="tag">
<span style ="margin-right: 64px"><span class = "tags" style = "font-size: ${tag.value[1]};"><c:out value = "${tag.key}"/></span>(${tag.value[0]})</span>
</c:forEach>
</div>
<div id="coocurrence">
<h4>Co-occurrence </h4>
<c:forEach var = "i" begin="0" end="${ fn:length(coocurrence) -1}">
<c:forEach var = "j" begin="0" end="${ fn:length(coocurrence[i]) -1}">
<c:choose>
<c:when test="${j == 0}">
<c:out value="${coocurrence[i][j]} :"/><br>
</c:when>
<c:otherwise>
<span style ="margin-left: 30px">- <c:out value="${coocurrence[i][j]}"/></span><br>
</c:otherwise>
</c:choose>
</c:forEach>
<br>
</c:forEach>
</div>
<br>
<br>
<div id="concordance">
<h4>Concordance </h4>
<c:forEach var = "i" begin="0" end="${ fn:length(concordance) -1}">
<c:forEach var = "j" begin="0" end="${ fn:length(concordance) -2}">
<c:choose>
<c:when test="${j == 0}">
<c:out value="${concordance[i][j]} :"/><br>
</c:when>
<c:otherwise>
<span style ="margin-left: 30px">"<c:out value="${concordance[i][j]}"/>"</span><br>
</c:otherwise>
</c:choose>
</c:forEach>
<br>
</c:forEach>
</div>
</c:if>
<c:if test="${not empty prettyOutput}">
<h3>Résultat Etude Controlée :</h3>
<table>
<tr>
<th>Concept</th>
<th>Concept supérieur</th>
<th>Concept(s) référent(s)</th>
<th>Concept(s) reliés</th>
<th>Valeur</th>
</tr>
<c:forEach items="${prettyOutput}" var="o">
<tr>
<td><c:out value="${o['node']}"/></td>
<td><c:out value="${o['broader']}"/></td>
<td><c:out value="${o['narrower']}"/></td>
<td><c:out value="${o['related']}"/></td>
<td><c:out value="${o['nRank']}"/></td>
</tr>
</c:forEach>
</table>
</c:if>
</body>
</html>
And the sevlet code :
package laetan.web.servlets;
import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import laetan.web.model.analyzer.TextAnalyzer;
import laetan.web.model.builder.FileLoader;
import laetan.web.model.builder.Vocabulary;
public class Analyzer extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
FileLoader.getThesaurii(request,true);
FileLoader.getModels(request,true);
this.getServletContext().getRequestDispatcher( "/WEB-INF/input.jsp" ).forward( request, response );
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
String f = request.getParameter("file");
Vocabulary vocabulary = new Vocabulary(request,"load");
@SuppressWarnings("unused")
TextAnalyzer analyze = new TextAnalyzer(request, vocabulary);
this.getServletContext().getRequestDispatcher( "/WEB-INF/input.jsp" ).forward( request, response );
}
}
In the servlet, f is null.