This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!