Revision 510
Added by bojilova over 23 years ago
MetaCatServlet.java | ||
---|---|---|
400 | 400 |
conn = util.getConnection(); |
401 | 401 |
DBTransform trans = new DBTransform(conn); |
402 | 402 |
response.setContentType("text/html"); |
403 |
// user authentication successful |
|
404 |
if (isValid) { |
|
405 |
// trans.transformXMLDocument(sess.getMessage(), "-//NCEAS//login//EN", |
|
406 |
// "-//W3C//HTML//EN", out); |
|
407 |
response.sendRedirect( |
|
408 |
response.encodeRedirectUrl(htmlpath + "/metacat.html")); |
|
409 |
|
|
410 |
// unsuccessful user authentication |
|
411 |
} else { |
|
412 |
// trans.transformXMLDocument(sess.getMessage(), "-//NCEAS//nologin//EN", |
|
413 |
// "-//W3C//HTML//EN", out); |
|
414 |
response.sendRedirect(htmlpath + "/login.html"); |
|
415 |
} |
|
403 |
trans.transformXMLDocument(sess.getMessage(), "-//NCEAS//login//EN", |
|
404 |
"-//W3C//HTML//EN", out); |
|
416 | 405 |
util.returnConnection(conn); |
417 | 406 |
} catch(Exception e) { |
418 | 407 |
util.returnConnection(conn); |
... | ... | |
423 | 412 |
response.setContentType("text/xml"); |
424 | 413 |
out.println(sess.getMessage()); |
425 | 414 |
} |
415 |
|
|
416 |
/* WITHOUT XSLT transformation |
|
417 |
// redirects response to html page |
|
418 |
if (qformat.equals("html")) { |
|
419 |
// user authentication successful |
|
420 |
if (isValid) { |
|
421 |
response.sendRedirect( |
|
422 |
response.encodeRedirectUrl(htmlpath + "/metacat.html")); |
|
423 |
// unsuccessful user authentication |
|
424 |
} else { |
|
425 |
response.sendRedirect(htmlpath + "/login.html"); |
|
426 |
} |
|
427 |
// any output is returned |
|
428 |
} else { |
|
429 |
response.setContentType("text/xml"); |
|
430 |
out.println(sess.getMessage()); |
|
431 |
} |
|
432 |
*/ |
|
426 | 433 |
|
427 |
// if (action.equals("Login Client")) { |
|
428 |
// out.println(sess.getMessage()); |
|
429 |
// } else { |
|
430 |
// try { |
|
431 |
// if (isValid) { |
|
432 |
// if (un.equals("public")) { |
|
433 |
// response.sendRedirect( |
|
434 |
// response.encodeRedirectUrl(htmlpath + "/index.html")); |
|
435 |
// } else { |
|
436 |
// response.sendRedirect( |
|
437 |
// response.encodeRedirectUrl(htmlpath + "/metacat.html")); |
|
438 |
// } |
|
439 |
// } else { |
|
440 |
// response.sendRedirect(htmlpath + "/login.html"); |
|
441 |
// } |
|
442 |
// } catch ( java.io.IOException ioe) { |
|
443 |
// String message = "handleLoginAction() - " + |
|
444 |
// "Error on redirect of HttpServletResponse: " + |
|
445 |
// ioe.getMessage(); |
|
446 |
// out.println(message); |
|
447 |
// } |
|
448 |
// } |
|
449 | 434 |
} |
450 | 435 |
|
451 | 436 |
/** |
... | ... | |
463 | 448 |
// produce output |
464 | 449 |
StringBuffer output = new StringBuffer(); |
465 | 450 |
output.append("<?xml version=\"1.0\"?>"); |
466 |
output.append("<success>");
|
|
467 |
output.append("User logout.");
|
|
468 |
output.append("</success>");
|
|
451 |
output.append("<logout>");
|
|
452 |
output.append("User logged out");
|
|
453 |
output.append("</logout>");
|
|
469 | 454 |
|
470 | 455 |
//format and transform the output |
471 | 456 |
if (qformat.equals("html")) { |
... | ... | |
474 | 459 |
conn = util.getConnection(); |
475 | 460 |
DBTransform trans = new DBTransform(conn); |
476 | 461 |
response.setContentType("text/html"); |
477 |
//trans.transformXMLDocument(output, "-//NCEAS//logout//EN", |
|
478 |
// "-//W3C//HTML//EN", out); |
|
479 |
response.sendRedirect(htmlpath + "/index.html"); |
|
462 |
trans.transformXMLDocument(output.toString(), "-//NCEAS//login//EN", |
|
463 |
"-//W3C//HTML//EN", out); |
|
480 | 464 |
util.returnConnection(conn); |
481 | 465 |
} catch(Exception e) { |
482 | 466 |
util.returnConnection(conn); |
... | ... | |
487 | 471 |
out.println(output.toString()); |
488 | 472 |
} |
489 | 473 |
|
474 |
/* WITHOUT XSLT transformation |
|
475 |
// redirects response to html page |
|
476 |
if (qformat.equals("html")) { |
|
477 |
response.sendRedirect(htmlpath + "/index.html"); |
|
478 |
} catch(Exception e) { |
|
479 |
util.returnConnection(conn); |
|
480 |
} |
|
481 |
// any output is returned |
|
482 |
} else { |
|
483 |
response.setContentType("text/xml"); |
|
484 |
out.println(output.toString()); |
|
485 |
} |
|
486 |
*/ |
|
490 | 487 |
} |
491 | 488 |
|
492 | 489 |
|
Also available in: Unified diff
XSLT transformation on "login" and "logout" action