0

I am using the onload method in the form like below in one of my servlet:

out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"       \"http://www.w3.org/TR/html4/loose.dtd\"> \n");
out.write("<html><body onload=\"document.forms[0].submit()\">\n");
out.write("<form method=\"POST\" action=\"http://ipaddress:8085/internal/Logout\">\n");
out.write("<input type=\"hidden\" name=\"groupId\" value=\"" + groupId
        + "\"/>\n");
out.write("<input type=\"hidden\" name=\"userName\" value=\""
        + userName + "\"/>\n");
out.write("<input type=\"hidden\" name=\"idpServer\" value=\""
        + idpServer + "\"/>\n");
out.write("<input type=\"hidden\" name=\"sessionId\" value=\""
        + sessionId + "\"/>\n");
out.write("<input type=\"hidden\" name=\"targetPage\" value=\""
        + targetPageURL + "\"/>\n");

out.write("<input type=\"hidden\" name=\"locale\" value=\""
        + locale + "\"/>\n");
out.write("<input type=\"hidden\" name=\"logoutPage\" value=\""
        + logoutPage + "\"/>\n");

out.write("</form>\n</body>\n</html>\n");

After the above code i have one more line which is like

deleteExpiredSession(sessionId);

In the first code block we have 'onload' method which will automatically submits the form to action url but in my case it is not happening the control is going to some other servlet.

  • In debug mode the code executing along with the second part of code(deleteExpiredSession(sessionId);), I think the second part should not be executed because the above code is having onload. Earlier it was working fine but suddenly it is stopped working. I think recently we migrated to tomcat6 - tomcat7. Is this the reason? Any suggestions would be great.
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
User
  • 173
  • 1
  • 12
  • separate view and controller first, this is a challenge to maintain this way http://stackoverflow.com/questions/5818101/why-business-logic-should-be-moved-out-of-jsp – jmj Dec 31 '14 at 06:56
  • yes that's right @JigarJoshi, I will separate it, i do not know why it is not able to submit the form to action url – User Dec 31 '14 at 07:05
  • The URL that you submit your post to is not valid (`http://ipaddress:port/internal/Logout`) – Erwin Bolwidt Dec 31 '14 at 10:14
  • The url is correct, please see edited post. – User Dec 31 '14 at 10:25

1 Answers1

0

I tested your application and I found out the problem is about your action address and id is not valid. You doesn't put port word after : in your URL. Change it to following code and it will work:

<form method="get" action="http://ipaddress:8080/internal/Logout" >
 ...

I replaced 8080 with port.

Ali Sepehri.Kh
  • 2,468
  • 2
  • 18
  • 27