Egy xml-ben tárolom a
változókat
oldalanként, meg azt hogy adott user esetén fel kell-e dolgozni az
oldalt.
protected void
processRequest(HttpServletRequest request, HttpServletResponse
response)
throws ServletException,
IOException {
String
pageNamePrefix =
"page";
session =
request.getSession();
if
(session.getAttribute("id")
!= null) {
pageHandler = new
PageHandler2(request, response); //változók ellenőrzését
végző bean
RequestDispatcher dispatcher =
null;
from =
(String)session.getAttribute("whereFrom"); //honnan
jön
if
("login".equals(from)) {
dispatcher =
request.getRequestDispatcher(pageNamePrefix +
"1.jsp");
dispatcher.forward(request, response);
return;
}
Integer i =
Integer.valueOf(from);
try { //szakirányonként
különböző kérdéscsoportok
lehetnek
String xmlPaths =
SurveyProperties.getProperty(session,
"configDir");
File file = new
File(session.getAttribute("realPath") + xmlPaths +
"/fieldDefs.xml");
DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc =
builder.parse(file);
Element element =
(Element)XPathAPI.selectSingleNode(doc,
"/survey/fields[@page='" +
from + "']");
boolean needWork = false;
String backNamePostfix =
"";
if
(!element.hasAttribute("profession1") &&
!element.hasAttribute("profession2") &&
!element.hasAttribute("profession3"))
{
needWork = true;
} else {
if
(element.hasAttribute("profession1") &&
(element.getAttribute("profession1")).contains((String)session.
getAttribute("Fach1")))
{
needWork =
true;
backNamePostfix =
element.getAttribute("backNamePostfix1");
}
if
(element.hasAttribute("profession2") &&
(element.getAttribute("profession2")).contains((String)session.
getAttribute("Fach2")))
{
needWork =
true;
backNamePostfix =
element.getAttribute("backNamePostfix2");
}
if (element.hasAttribute("profession3")
&&
(element.getAttribute("profession3")).contains((String)session.
getAttribute("Fach3")))
{
needWork =
true;
backNamePostfix =
element.getAttribute("backNamePostfix3");
}
}
if
(request.getParameter("next") != null) {
//előre
if (needWork)
if
(pageHandler.setVariables(from)) { //kötelező változók
ellenőrzése
if
(!element.hasAttribute("last")) {
//next prefix
megkeresése
element =
(Element)XPathAPI.selectSingleNode(doc,
"/survey/fields[@page='" +
String.valueOf(i+1) + "']");
String
nextNamePostfix = "";
if
(element.hasAttribute("profession1") &&
(element.getAttribute("profession1")).contains((String)session.
getAttribute("Fach1")))
{
nextNamePostfix =
element.getAttribute("backNamePostfix1");
}
if
(element.hasAttribute("profession2") &&
(element.getAttribute("profession2")).contains((String)session.
getAttribute("Fach2")))
{
nextNamePostfix =
element.getAttribute("backNamePostfix2");
}
if
(element.hasAttribute("profession3") &&
(element.getAttribute("profession3")).contains((String)session.
getAttribute("Fach3")))
{
nextNamePostfix =
element.getAttribute("backNamePostfix3");
}
String toPage =
pageNamePrefix + String.valueOf(i+1) +
".jsp";
dispatcher =
request.getRequestDispatcher(toPage);
dispatcher.forward(request, response);
} else {
//mentés
dispatcher =
request.getRequestDispatcher("save.jsp");
dispatcher.forward(request, response);
}
} else { //vissza,
hiba
dispatcher =
request.getRequestDispatcher(pageNamePrefix + from + backNamePostfix +
".jsp");
dispatcher.forward(request, response);
}
} else { //vissza, gomb
String toPage =
pageNamePrefix + String.valueOf(i-1) +
".jsp";
dispatcher =
request.getRequestDispatcher(toPage);
dispatcher.forward(request,
response);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
else
response.sendRedirect(response.encodeRedirectURL("login.jsp"));
}
From:
javalist@javasite.bme.hu [mailto:javalist@javasite.bme.hu]
Sent: Wednesday, August
02, 2006
6:55 PM
To:
javalist@javasite.bme.hu
Subject: [Java lista] Re:
tomcat
error?
On 8/2/06, javalist@javasite.bme.hu
<javalist@javasite.bme.hu
>
wrote:
*** Felado:
jnak <junknak@index.hu > ***
esetleg valami kod?
udv, t
Kódja biztos van neki :)
üdv
Zs