File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with encodeURL

 
Hui Ge
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My doPost method:

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
String userid = req.getParameter("userid");
String password = req.getParameter("password");


if (userid != null && password != null && userid.length() > 0 && password.length() > 0) {

ServletConfig config = getServletConfig();
ServletContext context = config.getServletContext();
//context param
String driverClassName = context.getInitParameter("driverClassName");
String dbUsername = context.getInitParameter("dbUsername");
String dbPassword = context.getInitParameter("dbPassword");
//config param
String dburl = config.getInitParameter("dburl");

MySqlDAO dao = new MySqlDAO();
try {
dao.init(driverClassName, dburl, dbUsername, dbPassword);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
throw new ServletException("ClassNotFoundException", e1);
} catch (SQLException e1) {
e1.printStackTrace();
throw new ServletException("SQLException", new SQLException());
}
try {
UserObject userObj = dao.verifyUser(userid, password);
if( userObj != null) {
HttpSession session = req.getSession();
session.setAttribute("userObj", userObj);
ServletContext ct = getServletContext();
String url = res.encodeURL("/jsp/welcome.jsp");
RequestDispatcher rd = ct.getRequestDispatcher(url);
rd.forward(req, res);
} else {
res.setStatus(HttpServletResponse.SC_FORBIDDEN);}
} catch (SQLException e) {
e.printStackTrace();
throw new ServletException("SQLException", e);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}


} else {
res.sendError(HttpServletResponse.SC_FORBIDDEN);
}
return;
}

Sorry about the formatting. I would expect the url String to consist of the JSESSIONID but it didn't. Anyone knows why?
 
Vijay Kiran
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your browser accepts cookies the URL will never contain the JSESSIONID parameter.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic