开发者

How to redirect page

Hi i created one java application in which i tried to open my company's standard login page and i planned to redirect the link to open my own design page. Standard login page is displayed, instead of going to my own design page as usual its going to mail page. After sign out the mail page i'm gettting my own design page. But my need is, when i sign in the standard login page it should diplay my own design page. Is it possible? Please Help me.

And this is code that i followed import java.io.IOException;

import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.UserService; import com.google.appengine.api.users.UserServiceFactory; import com.google.appengine.api.users.User; public class New extends HttpServlet { /** * */ private static final long serialVersionUID = 1L;

public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); resp.setContentType("text/html");

  UserService userService = UserServiceFactory.getUserService();
      User user = userService.getCurrentUser();

      if (user != null) {

          if(user.getEmail().equals("xxx@yy.edu.in")) {
              resp.getWriter().println("done");
              resp.sendRedirect("/login.jsp");
          }
          else {
              resp.getWriter().println("Hello, " + user.getNickname()+"<br>");
              resp.getWriter().println("Thanks for your interest. But this application is still not available to everybody.");
              resp.getWriter().println("<a href="+UserServiceFactory.getUserService().createLogoutURL(userService.createLoginURL(req.getRequestURI()))+">Log out</a>");
          }
     开发者_运维百科 } else {
          resp.sendRedirect(userService.createLoginURL("http://mail.yyy.edu.in"));
      }       

}

}

Thanks in advance Regards Sharun.


Using HttpServletResponse you have the method void sendRedirect(java.lang.String location).


Try removing the line

resp.getWriter().println("done");

before the

resp.sendRedirect("/login.jsp");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜