Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

sendRedirect method not working

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic