How to redirect page
Posted
by sharun
on Stack Overflow
See other posts from Stack Overflow
or by sharun
Published on 2010-03-19T06:58:26Z
Indexed on
2010/03/19
7:01 UTC
Read the original article
Hit count: 281
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("[email protected]")) {
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.
© Stack Overflow or respective owner