aspose file tools*
The moose likes JSP and the fly likes link html to controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "link html to controller" Watch "link html to controller" New topic
Author

link html to controller

Cecilia Stesser
Greenhorn

Joined: Feb 29, 2008
Posts: 2
Hi
I want to link a jsp page to a controller, but it doesent work. I�m greatful for all the help I can get.

Here is the link code from the jsp:
<a href = "Logout"> Logout </a>

Here is the code from the controller:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

HttpSession session = request.getSession();

String loggedOut = "/pages/loggedout_text.jsp";

RequestDispatcher view = request.getRequestDispatcher(loggedOut);
view.forward(request, response);
System.out.println("Hej");
session.invalidate();
}

Here is the code from from the loggedout_text.jsp:
Error
<p />
You are logged out.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Cecilia Stesser:
I want to link a jsp page to a controller, but it doesent work. I�m greatful for all the help I can get.


What doesn't work?
What errors are you seeing?
What IS happening?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Cecilia Stesser
Greenhorn

Joined: Feb 29, 2008
Posts: 2
I am not getting any error messages, just a blank page.

But I know that my jsp sight doesent get a connection with the controller (Logout) page, because my sysos in the Logout isnt even written out.

I have checked my xml and that seems to work fine.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The first thing I do when I see a blank page is use the browser's 'view source' feature to look at what's really coming from the server, if anything.

Often this a simple HTML error like a missing quote or a script tag that wasn't closed properly.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

<a href = "Logout"> Logout </a>
That doesn't look like a properly formed URL to your servlet to me.

How did you map the servlet in web.xml?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: link html to controller
 
Similar Threads
logout by disabling back button
URL not getting through to servlet
View resolver is not able to identify the correct view
Validation and HttpSession
Spring : how to redirect to login page on session timeout