servlet just displays null on black page and does not doPost().?

Daniel Rinaldi May 29, 2012

I am trying to execute code in a servlet but it doesnt execute anything in the doPost() method. Instead when the servlet is accessed it shows a blank page with "null" in its body.

this is how i call the vm(which works):

protected String doExecute() throws Exception
{
return MULTIPLEVERSION;
}
this is the code for the vm(which works):
<html>
<head>
	<title>Warning</title>
</head>

<body class="lp">

<div class="module xsrf">
    <div class="mod-header">
        <h3>Warning</h3>
    </div>
    <div class="mod-content">
        <div class="notify warn">
<span style="color:#cc0000;font-weight:bold;">Confirmation</span>
<form name="multipleVersionForm" action="$theurl/plugins/servlet/aServlet" method="post" >
<input id="projectId" type="hidden" value="$projectId" >
<input id="versionName" type="hidden" value="$versionName" >
<input id="theNewDate" type="hidden" value="$theNewDate" >
<p>Do you wish to update 'SW Ready - 3 Weeks?'s Release date as well?</p>
<p><input type="submit" value="Yes" ></input>
<button onclick="history.go(-2);">No</button></p>
            </form>
        </div>
    </div>
</div>

</body>
</html>

and when i hit the yes button it goes to .../plugins/servlet/aServlet (the Correct servlet) which is this:

public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.getOutputStream().println("HI");
}

The Problem is that it is not executing the code in the doPost the page appears blank with only the word "null" in its body. Can anyone point out the problem?

1 answer

1 accepted

0 votes
Answer accepted
sm shamim May 29, 2012

Your doPost() is probably never getting executed. With my experiment I have found out that when the page is displayed, the action element of the form automatically has the correct url to the servlet. So, just keep the action element empty and see if it works

<form name="multipleVersionForm" action="" method="post" >

Daniel Rinaldi May 29, 2012

so i tried setting action to "" but that just gave me this error:

JIRA could not complete this action due to a missing form token.

You may have been away from your web browser for a while, which could have resulted in the expiry of your current form token. A new form token has been reissued.

JIRA administrators : Please refer to this page for details on disabling form token checking.

Problematic action : ExtendedEditVersionDetails.jspa

sm shamim May 30, 2012

Openup firebug and see the url where your submit getting posted, in other words look for the url that has been substituted in the action element.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events