• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

sendRedirect method not working

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using Websphere 4.0.6 to host my application involving servlets and jsps.
But when I invoke response.sendRedirect method from the servlet class, to an HTML page, I get a HTTP 404 Not Found error. Also, no error message is thrown on the server console.
The same code works on Websphere 5.1.1

I even tried using both the absolute and relative paths as argument to the sendRedirect method, but no change in the response.

Here's the code snippet:

public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

PrintWriter out = null;
HttpSession session = null;

try {
out = resp.getWriter();
String source = req.getParameter("source");
String action = req.getParameter("action");

UserLoginBean userBean = null;

if (source != null) {
if (source.equals("login")) { //validating the login
String loginId = req.getParameter("LoginID");
String password = req.getParameter("Password");
ValidateLogin vLogin = new ValidateLogin();
boolean validLogin = vLogin.validate(loginId, password);
if (validLogin) {
session = req.getSession(true);
session.setAttribute("loginID", loginId);
boolean firstLogin = vLogin.firstLogin;
if (!firstLogin) {
ViewSchedule viewSchedule = new ViewSchedule();
ArrayList courseList = viewSchedule.getCourseDetails();
session.setAttribute("CourseList", courseList);
UserLoginBean userLoginBean = new UserLoginBean(loginId);
session.setAttribute("userloginbean", userLoginBean);
resp.sendRedirect("/TrainingNomination/HTML/home.html");
}
}
}
}
} catch (Exception e) {
LOG.error("Exception occurred ", e);
} finally {
if (out != null) {
out.close();
}
}
}


Please let me know the cause of this error.
Thanking in advance,
praveen.
 
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read this document
Maybe you'll find interesting information to figure out the different behaviors between WAS 5 and WAS 4 you have noticed.
 
praveen pillai
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a ton, Jean-Louis.
This document helped me resolve my problem.
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by praveen pillai:
Thanks a ton, Jean-Louis.
This document helped me resolve my problem.



u'r welcome . thanks for your feedback
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic