Java Code Examples for org.apache.wicket.request.http.WebResponse#setStatus()

The following examples show how to use org.apache.wicket.request.http.WebResponse#setStatus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedirectRequestHandler.java    From onedev with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
public void respond(final IRequestCycle requestCycle)
{
	String location = requestCycle.getUrlRenderer().renderRelativeUrl(Url.parse(getRedirectUrl()));
	
	WebResponse response = (WebResponse)requestCycle.getResponse();

	if (status == HttpServletResponse.SC_MOVED_TEMPORARILY)
	{
		response.sendRedirect(location);
	}
	else
	{
		response.setStatus(status);

		if (((WebRequest)requestCycle.getRequest()).isAjax())
		{
			response.setHeader("Ajax-Location", location);
		}
		else
		{
			response.setHeader("Location", location);
		}
	}
}
 
Example 2
Source File: AbstractPlainTextPage.java    From the-app with Apache License 2.0 5 votes vote down vote up
private WebResponse newStringResponse() {
    WebResponse response = (WebResponse) getResponse();
    response.setContentType("text/plain");
    response.write(responseText());
    response.flush();
    response.setStatus(HttpStatus.OK.value());
    return response;
}
 
Example 3
Source File: AbstractPlainTextPage.java    From AppStash with Apache License 2.0 5 votes vote down vote up
private WebResponse newStringResponse() {
    WebResponse response = (WebResponse) getResponse();
    response.setContentType("text/plain");
    response.write(responseText());
    response.flush();
    response.setStatus(HttpStatus.OK.value());
    return response;
}
 
Example 4
Source File: HelloDbResponse.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void respond(Attributes attributes) 
{
 final StringValue queriesParam = attributes.getRequest().getQueryParameters().getParameterValue("queries");
 int qs = queriesParam.toInt(1);
 if (qs < 1)
 {
  qs = 1;
 }
 else if (qs > 500)
 {
  qs = 500;
 }
 final int queries = qs;

 try 
 {
byte[] data = getDataFromDatabase(queriesParam, queries);

final WebResponse webResponse = (WebResponse) attributes.getResponse();
webResponse.setContentLength(data.length);
webResponse.setContentType(HelloJsonResponse.APPLICATION_JSON);
webResponse.write(data);
 } 
 catch (Exception ex)
 {
WebResponse response = (WebResponse) attributes.getResponse();

response.setContentType(TEXT_PLAIN);
response.setStatus(500);
response.write(ex.getClass().getSimpleName() + ": " + ex.getMessage());

ex.printStackTrace();
 }
}
 
Example 5
Source File: AccessDeniedPage.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
protected void setHeaders(final WebResponse response)
{
	response.setStatus(HttpServletResponse.SC_FORBIDDEN);
}
 
Example 6
Source File: ExpiredPage.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
protected void setHeaders(final WebResponse response)
{
	response.setStatus(HttpServletResponse.SC_GONE);
}
 
Example 7
Source File: NotFoundPage.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
protected void setHeaders(WebResponse response) {
	response.setStatus(HttpServletResponse.SC_FORBIDDEN);
}