You are on page 1of 3

RSS Email Followus Becomeafan

JavaExamples
LearnJavaProgrammingbyExamples
Searchthissite...
Youarehere:Home Servlet HowdoIsendaresponsestatusinservlet? January21,20144:05pm
0
SubmitComment
HowdoIsendaresponsestatusinservlet?
PostedbyWayanSaryada onFebruary10,2007
HereisalistofallavailablestatuscodethataredefinedintheHttpServletResponseclass.
StatusCode Description
SC_ACCEPTED
Statuscode(202)indicatingthatarequestwasacceptedforprocessing,butwasnot
completed
SC_BAD_GATEWAY
Statuscode(502)indicatingthattheHTTPserverreceivedaninvalidresponsefroma
serveritconsultedwhenactingasaproxyorgateway
SC_BAD_REQUEST Statuscode(400)indicatingtherequestsentbytheclientwassyntacticallyincorrect
SC_CONFLICT
Statuscode(409)indicatingthattherequestcouldnotbecompletedduetoaconflict
withthecurrentstateoftheresource
SC_CONTINUE Statuscode(100)indicatingtheclientcancontinue
SC_CREATED
Statuscode(201)indicatingtherequestsucceededandcreatedanewresourceonthe
server
SC_EXPECTATION_FAILED
Statuscode(417)indicatingthattheservercouldnotmeettheexpectationgiveninthe
Expectrequestheader
SC_FORBIDDEN Statuscode(403)indicatingtheserverunderstoodtherequestbutrefusedtofulfillit
SC_FOUND Statuscode(302)indicatingthattheresourceresidetemporarilyunderadifferentURI
SC_GATEWAY_TIMEOUT
Statuscode(504)indicatingthattheserverdidnotreceiveatimelyresponsefromthe
upstreamserverwhileactingasagatewayorproxy
SC_GONE
Statuscode(410)indicatingthattheresourceisnolongeravailableattheserverand
noforwardingaddressisknown
SC_HTTP_VERSION_NOT_SUPPORTED
Statuscode(505)indicatingthattheserverdoesnotsupportorrefusestosupportthe
HTTPprotocolversionthatwasusedintherequestmessage
SC_INTERNAL_SERVER_ERROR
Statuscode(500)indicatinganerrorinsidetheHTTPserverwhichpreventeditfrom
fulfillingtherequest
SC_LENGTH_REQUIRED
Statuscode(411)indicatingthattherequestcannotbehandledwithoutadefined
ContentLength
SC_METHOD_NOT_ALLOWED
Statuscode(405)indicatingthatthemethodspecifiedintheRequestLineisnot
allowedfortheresourceidentifiedbytheRequestURI
SC_MOVED_PERMANENTLY
Statuscode(301)indicatingthattheresourcehaspermanentlymovedtoanew
location,andthatfuturereferencesshoulduseanewURIwiththeirrequests
SC_MOVED_TEMPORARILY
Statuscode(302)indicatingthattheresourcehastemporarilymovedtoanother
location,butthatfuturereferencesshouldstillusetheoriginalURItoaccessthe
resource
SC_MULTIPLE_CHOICES
Statuscode(300)indicatingthattherequestedresourcecorrespondstoanyoneofa
setofrepresentations,eachwithitsownspecificlocation
SC_NO_CONTENT
Statuscode(204)indicatingthattherequestsucceededbutthattherewasnonew
informationtoreturn
SC_NON_AUTHORITATIVE_INFORMATION
Statuscode(203)indicatingthatthemetainformationpresentedbytheclientdidnot
originatefromtheserver
SC_NOT_ACCEPTABLE
Statuscode(406)indicatingthattheresourceidentifiedbytherequestisonlycapable
ofgeneratingresponseentitieswhichhavecontentcharacteristicsnotacceptable
accordingtotheacceptheaderssentintherequest
SC_NOT_FOUND Statuscode(404)indicatingthattherequestedresourceisnotavailable
SC_NOT_IMPLEMENTED
Statuscode(501)indicatingtheHTTPserverdoesnotsupportthefunctionalityneeded
tofulfilltherequest
SC_NOT_MODIFIED
Statuscode(304)indicatingthataconditionalGEToperationfoundthattheresource
wasavailableandnotmodified
SC_OK Statuscode(200)indicatingtherequestsucceedednormally
SC_PARTIAL_CONTENT
Statuscode(206)indicatingthattheserverhasfulfilledthepartialGETrequestforthe
resource
SC_PAYMENT_REQUIRED Statuscode(402)reservedforfutureuse
SC_PRECONDITION_FAILED
Statuscode(412)indicatingthatthepreconditiongiveninoneormoreoftherequest
headerfieldsevaluatedtofalsewhenitwastestedontheserver
SC_PROXY_AUTHENTICATION_REQUIRED Statuscode(407)indicatingthattheclientMUSTfirstauthenticateitselfwiththeproxy
SC_REQUEST_ENTITY_TOO_LARGE
Statuscode(413)indicatingthattheserverisrefusingtoprocesstherequestbecause
therequestentityislargerthantheserveriswillingorabletoprocess
SC_REQUEST_TIMEOUT
Statuscode(408)indicatingthattheclientdidnotproducearequestwithinthetimethat
theserverwaspreparedtowait
SC_REQUEST_URI_TOO_LONG
Statuscode(414)indicatingthattheserverisrefusingtoservicetherequestbecause
theRequestURIislongerthantheserveriswillingtointerpret
SC_REQUESTED_RANGE_NOT_SATISFIABLEStatuscode(416)indicatingthattheservercannotservetherequestedbyterange
SC_RESET_CONTENT
Statuscode(205)indicatingthattheagentSHOULDresetthedocumentviewwhich
causedtherequesttobesent
SC_SEE_OTHER
Statuscode(303)indicatingthattheresponsetotherequestcanbefoundundera
differentURI
SC_SERVICE_UNAVAILABLE
Statuscode(503)indicatingthattheHTTPserveristemporarilyoverloaded,andunable
tohandletherequest
SC_SWITCHING_PROTOCOLS
Statuscode(101)indicatingtheserverisswitchingprotocolsaccordingtoUpgrade
header
SC_TEMPORARY_REDIRECT
Statuscode(307)indicatingthattherequestedresourceresidestemporarilyundera
differentURI
SC_UNAUTHORIZED Statuscode(401)indicatingthattherequestrequiresHTTPauthentication
SC_UNSUPPORTED_MEDIA_TYPE
Statuscode(415)indicatingthattheserverisrefusingtoservicetherequestbecause
theentityoftherequestisinaformatnotsupportedbytherequestedresourceforthe
requestedmethod
SC_USE_PROXY
Statuscode(305)indicatingthattherequestedresourceMUSTbeaccessedthrough
theproxygivenbytheLocationfield
RelatedPosts
HowdoIsendacookieinServlet?
HowdoIgetclientIPandhostnameinServlet?
HowdoIreadcookieinServlet?
HowdoIgetservletrequestURLinformation?
HowdoIreadservletinitparameter?
HowdoIgetservletrequestheadersinformation?
HowdoIdeleteacookieinServlet?
Filedin:Servlet
AboutWayanSaryada
Iamaprogrammer,arunner,anopenwaterdiverandcurrentlylivingintheislandofBali,Indonesia.
ViewallpostsbyWayanSaryada
LeaveaReply
Name(Required)
Mail(willnotbepublished)(Required)
Website
WorkfromHome
RecentProjects
Findmoreprojects
Poweredby
Pages RecentPosts RecentComments JavaResources
AffiliateLinks
2014JavaExamples.Allrightsreserved.
Find us on Facebook
Learn by Examples
119 people like Learn by Examples.
Facebook social plugin
Like Like
$30250
View
NeedaClient/Server(MySQL)studentrecord
application...
$30250
View
SimpleJavaProgrammingofWhitepaperScript
/Algorithm(Image/Video)(URLfixed!)...
$30250
View
AndroidandIOSforexmarginapp
android,ipad,iphone,java,mobilephone,app,...
PostaProject
About
Bookstore
HowdoIcreateasimplemail
clientprograminSwing?
Whatarethesystem
propertiesusedforsending
email?
HowdoIsendanHTML
email?
HowdoIreadlastncharacters
fromafile?
JavaSEInstallationTutorial
PierreonHowdoIsendemail
usingGmailviaTLS?
PreethionHowdoImove
focusfromJTextAreausing
TABkey?
AmitonHowdoIgetoperating
systemtemporarydirectory/
folder?
SrinonHowtomonitorfileor
directorychanges?
SrinonHowtomonitorfileor
directorychanges?
JavaLanguageSpecification
JavaSETechnicalDocumentation
JavaTutorials
JavaEETechnicalDocumentation
JavaEE7Tutorials
ShopTechTitlesonoreilly.com
50%offhostingplansfromGoDaddy!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.kodejava.example.servlet;
importjavax.servlet.ServletException;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importjava.io.IOException;
public class ResponseStatus extends HttpServlet {
protected void doGet(HttpServletRequestrequest,
HttpServletResponseresponse) throwsServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequestrequest,
HttpServletResponseresponse) throwsServletException, IOException {
//
//AllresponsestatusisdefinedintheHttpServletResponseclass.We
//canthenusetheseconstantsvaluetoreturnprocessstatustothe
//browser.
//
response.setContentType("text/html");
//
//LetsaythisservletonlyhandlerequestforpagenameinputForm.So
//whenuserrequestforotherpagenameerrorpagenotfound404will
//bereturned,otherwiseitwillbe200whichmeanOK.
//
String page = request.getParameter("page");
if (page != null && page.equals("inputForm")) {
response.setStatus(response.SC_OK);
} else {
response.sendError(response.SC_NOT_FOUND, "Therequestedpage["
+ page + "]notfound.");
}
}
}
About Bookstore
Home 1.JavaSEAPI 2.JavaEEAPI 3.Frameworks 4.OtherLibraries 5.DesignPatterns 6.IDE/Tools
Generated with www.html-to-pdf.net Page 1 / 3
RSS Email Followus Becomeafan
JavaExamples
LearnJavaProgrammingbyExamples
Searchthissite...
Youarehere:Home Servlet HowdoIsendaresponsestatusinservlet? January21,20144:05pm
0
SubmitComment
HowdoIsendaresponsestatusinservlet?
PostedbyWayanSaryada onFebruary10,2007
HereisalistofallavailablestatuscodethataredefinedintheHttpServletResponseclass.
StatusCode Description
SC_ACCEPTED
Statuscode(202)indicatingthatarequestwasacceptedforprocessing,butwasnot
completed
SC_BAD_GATEWAY
Statuscode(502)indicatingthattheHTTPserverreceivedaninvalidresponsefroma
serveritconsultedwhenactingasaproxyorgateway
SC_BAD_REQUEST Statuscode(400)indicatingtherequestsentbytheclientwassyntacticallyincorrect
SC_CONFLICT
Statuscode(409)indicatingthattherequestcouldnotbecompletedduetoaconflict
withthecurrentstateoftheresource
SC_CONTINUE Statuscode(100)indicatingtheclientcancontinue
SC_CREATED
Statuscode(201)indicatingtherequestsucceededandcreatedanewresourceonthe
server
SC_EXPECTATION_FAILED
Statuscode(417)indicatingthattheservercouldnotmeettheexpectationgiveninthe
Expectrequestheader
SC_FORBIDDEN Statuscode(403)indicatingtheserverunderstoodtherequestbutrefusedtofulfillit
SC_FOUND Statuscode(302)indicatingthattheresourceresidetemporarilyunderadifferentURI
SC_GATEWAY_TIMEOUT
Statuscode(504)indicatingthattheserverdidnotreceiveatimelyresponsefromthe
upstreamserverwhileactingasagatewayorproxy
SC_GONE
Statuscode(410)indicatingthattheresourceisnolongeravailableattheserverand
noforwardingaddressisknown
SC_HTTP_VERSION_NOT_SUPPORTED
Statuscode(505)indicatingthattheserverdoesnotsupportorrefusestosupportthe
HTTPprotocolversionthatwasusedintherequestmessage
SC_INTERNAL_SERVER_ERROR
Statuscode(500)indicatinganerrorinsidetheHTTPserverwhichpreventeditfrom
fulfillingtherequest
SC_LENGTH_REQUIRED
Statuscode(411)indicatingthattherequestcannotbehandledwithoutadefined
ContentLength
SC_METHOD_NOT_ALLOWED
Statuscode(405)indicatingthatthemethodspecifiedintheRequestLineisnot
allowedfortheresourceidentifiedbytheRequestURI
SC_MOVED_PERMANENTLY
Statuscode(301)indicatingthattheresourcehaspermanentlymovedtoanew
location,andthatfuturereferencesshoulduseanewURIwiththeirrequests
SC_MOVED_TEMPORARILY
Statuscode(302)indicatingthattheresourcehastemporarilymovedtoanother
location,butthatfuturereferencesshouldstillusetheoriginalURItoaccessthe
resource
SC_MULTIPLE_CHOICES
Statuscode(300)indicatingthattherequestedresourcecorrespondstoanyoneofa
setofrepresentations,eachwithitsownspecificlocation
SC_NO_CONTENT
Statuscode(204)indicatingthattherequestsucceededbutthattherewasnonew
informationtoreturn
SC_NON_AUTHORITATIVE_INFORMATION
Statuscode(203)indicatingthatthemetainformationpresentedbytheclientdidnot
originatefromtheserver
SC_NOT_ACCEPTABLE
Statuscode(406)indicatingthattheresourceidentifiedbytherequestisonlycapable
ofgeneratingresponseentitieswhichhavecontentcharacteristicsnotacceptable
accordingtotheacceptheaderssentintherequest
SC_NOT_FOUND Statuscode(404)indicatingthattherequestedresourceisnotavailable
SC_NOT_IMPLEMENTED
Statuscode(501)indicatingtheHTTPserverdoesnotsupportthefunctionalityneeded
tofulfilltherequest
SC_NOT_MODIFIED
Statuscode(304)indicatingthataconditionalGEToperationfoundthattheresource
wasavailableandnotmodified
SC_OK Statuscode(200)indicatingtherequestsucceedednormally
SC_PARTIAL_CONTENT
Statuscode(206)indicatingthattheserverhasfulfilledthepartialGETrequestforthe
resource
SC_PAYMENT_REQUIRED Statuscode(402)reservedforfutureuse
SC_PRECONDITION_FAILED
Statuscode(412)indicatingthatthepreconditiongiveninoneormoreoftherequest
headerfieldsevaluatedtofalsewhenitwastestedontheserver
SC_PROXY_AUTHENTICATION_REQUIRED Statuscode(407)indicatingthattheclientMUSTfirstauthenticateitselfwiththeproxy
SC_REQUEST_ENTITY_TOO_LARGE
Statuscode(413)indicatingthattheserverisrefusingtoprocesstherequestbecause
therequestentityislargerthantheserveriswillingorabletoprocess
SC_REQUEST_TIMEOUT
Statuscode(408)indicatingthattheclientdidnotproducearequestwithinthetimethat
theserverwaspreparedtowait
SC_REQUEST_URI_TOO_LONG
Statuscode(414)indicatingthattheserverisrefusingtoservicetherequestbecause
theRequestURIislongerthantheserveriswillingtointerpret
SC_REQUESTED_RANGE_NOT_SATISFIABLEStatuscode(416)indicatingthattheservercannotservetherequestedbyterange
SC_RESET_CONTENT
Statuscode(205)indicatingthattheagentSHOULDresetthedocumentviewwhich
causedtherequesttobesent
SC_SEE_OTHER
Statuscode(303)indicatingthattheresponsetotherequestcanbefoundundera
differentURI
SC_SERVICE_UNAVAILABLE
Statuscode(503)indicatingthattheHTTPserveristemporarilyoverloaded,andunable
tohandletherequest
SC_SWITCHING_PROTOCOLS
Statuscode(101)indicatingtheserverisswitchingprotocolsaccordingtoUpgrade
header
SC_TEMPORARY_REDIRECT
Statuscode(307)indicatingthattherequestedresourceresidestemporarilyundera
differentURI
SC_UNAUTHORIZED Statuscode(401)indicatingthattherequestrequiresHTTPauthentication
SC_UNSUPPORTED_MEDIA_TYPE
Statuscode(415)indicatingthattheserverisrefusingtoservicetherequestbecause
theentityoftherequestisinaformatnotsupportedbytherequestedresourceforthe
requestedmethod
SC_USE_PROXY
Statuscode(305)indicatingthattherequestedresourceMUSTbeaccessedthrough
theproxygivenbytheLocationfield
RelatedPosts
HowdoIsendacookieinServlet?
HowdoIgetclientIPandhostnameinServlet?
HowdoIreadcookieinServlet?
HowdoIgetservletrequestURLinformation?
HowdoIreadservletinitparameter?
HowdoIgetservletrequestheadersinformation?
HowdoIdeleteacookieinServlet?
Filedin:Servlet
AboutWayanSaryada
Iamaprogrammer,arunner,anopenwaterdiverandcurrentlylivingintheislandofBali,Indonesia.
ViewallpostsbyWayanSaryada
LeaveaReply
Name(Required)
Mail(willnotbepublished)(Required)
Website
WorkfromHome
RecentProjects
Findmoreprojects
Poweredby
Pages RecentPosts RecentComments JavaResources
AffiliateLinks
2014JavaExamples.Allrightsreserved.
Find us on Facebook
Learn by Examples
119 people like Learn by Examples.
Facebook social plugin
Like Like
$30250
View
NeedaClient/Server(MySQL)studentrecord
application...
$30250
View
SimpleJavaProgrammingofWhitepaperScript
/Algorithm(Image/Video)(URLfixed!)...
$30250
View
AndroidandIOSforexmarginapp
android,ipad,iphone,java,mobilephone,app,...
PostaProject
About
Bookstore
HowdoIcreateasimplemail
clientprograminSwing?
Whatarethesystem
propertiesusedforsending
email?
HowdoIsendanHTML
email?
HowdoIreadlastncharacters
fromafile?
JavaSEInstallationTutorial
PierreonHowdoIsendemail
usingGmailviaTLS?
PreethionHowdoImove
focusfromJTextAreausing
TABkey?
AmitonHowdoIgetoperating
systemtemporarydirectory/
folder?
SrinonHowtomonitorfileor
directorychanges?
SrinonHowtomonitorfileor
directorychanges?
JavaLanguageSpecification
JavaSETechnicalDocumentation
JavaTutorials
JavaEETechnicalDocumentation
JavaEE7Tutorials
ShopTechTitlesonoreilly.com
50%offhostingplansfromGoDaddy!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.kodejava.example.servlet;
importjavax.servlet.ServletException;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importjava.io.IOException;
public class ResponseStatus extends HttpServlet {
protected void doGet(HttpServletRequestrequest,
HttpServletResponseresponse) throwsServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequestrequest,
HttpServletResponseresponse) throwsServletException, IOException {
//
//AllresponsestatusisdefinedintheHttpServletResponseclass.We
//canthenusetheseconstantsvaluetoreturnprocessstatustothe
//browser.
//
response.setContentType("text/html");
//
//LetsaythisservletonlyhandlerequestforpagenameinputForm.So
//whenuserrequestforotherpagenameerrorpagenotfound404will
//bereturned,otherwiseitwillbe200whichmeanOK.
//
String page = request.getParameter("page");
if (page != null && page.equals("inputForm")) {
response.setStatus(response.SC_OK);
} else {
response.sendError(response.SC_NOT_FOUND, "Therequestedpage["
+ page + "]notfound.");
}
}
}
About Bookstore
Home 1.JavaSEAPI 2.JavaEEAPI 3.Frameworks 4.OtherLibraries 5.DesignPatterns 6.IDE/Tools
Generated with www.html-to-pdf.net Page 2 / 3
RSS Email Followus Becomeafan
JavaExamples
LearnJavaProgrammingbyExamples
Searchthissite...
Youarehere:Home Servlet HowdoIsendaresponsestatusinservlet? January21,20144:05pm
0
SubmitComment
HowdoIsendaresponsestatusinservlet?
PostedbyWayanSaryada onFebruary10,2007
HereisalistofallavailablestatuscodethataredefinedintheHttpServletResponseclass.
StatusCode Description
SC_ACCEPTED
Statuscode(202)indicatingthatarequestwasacceptedforprocessing,butwasnot
completed
SC_BAD_GATEWAY
Statuscode(502)indicatingthattheHTTPserverreceivedaninvalidresponsefroma
serveritconsultedwhenactingasaproxyorgateway
SC_BAD_REQUEST Statuscode(400)indicatingtherequestsentbytheclientwassyntacticallyincorrect
SC_CONFLICT
Statuscode(409)indicatingthattherequestcouldnotbecompletedduetoaconflict
withthecurrentstateoftheresource
SC_CONTINUE Statuscode(100)indicatingtheclientcancontinue
SC_CREATED
Statuscode(201)indicatingtherequestsucceededandcreatedanewresourceonthe
server
SC_EXPECTATION_FAILED
Statuscode(417)indicatingthattheservercouldnotmeettheexpectationgiveninthe
Expectrequestheader
SC_FORBIDDEN Statuscode(403)indicatingtheserverunderstoodtherequestbutrefusedtofulfillit
SC_FOUND Statuscode(302)indicatingthattheresourceresidetemporarilyunderadifferentURI
SC_GATEWAY_TIMEOUT
Statuscode(504)indicatingthattheserverdidnotreceiveatimelyresponsefromthe
upstreamserverwhileactingasagatewayorproxy
SC_GONE
Statuscode(410)indicatingthattheresourceisnolongeravailableattheserverand
noforwardingaddressisknown
SC_HTTP_VERSION_NOT_SUPPORTED
Statuscode(505)indicatingthattheserverdoesnotsupportorrefusestosupportthe
HTTPprotocolversionthatwasusedintherequestmessage
SC_INTERNAL_SERVER_ERROR
Statuscode(500)indicatinganerrorinsidetheHTTPserverwhichpreventeditfrom
fulfillingtherequest
SC_LENGTH_REQUIRED
Statuscode(411)indicatingthattherequestcannotbehandledwithoutadefined
ContentLength
SC_METHOD_NOT_ALLOWED
Statuscode(405)indicatingthatthemethodspecifiedintheRequestLineisnot
allowedfortheresourceidentifiedbytheRequestURI
SC_MOVED_PERMANENTLY
Statuscode(301)indicatingthattheresourcehaspermanentlymovedtoanew
location,andthatfuturereferencesshoulduseanewURIwiththeirrequests
SC_MOVED_TEMPORARILY
Statuscode(302)indicatingthattheresourcehastemporarilymovedtoanother
location,butthatfuturereferencesshouldstillusetheoriginalURItoaccessthe
resource
SC_MULTIPLE_CHOICES
Statuscode(300)indicatingthattherequestedresourcecorrespondstoanyoneofa
setofrepresentations,eachwithitsownspecificlocation
SC_NO_CONTENT
Statuscode(204)indicatingthattherequestsucceededbutthattherewasnonew
informationtoreturn
SC_NON_AUTHORITATIVE_INFORMATION
Statuscode(203)indicatingthatthemetainformationpresentedbytheclientdidnot
originatefromtheserver
SC_NOT_ACCEPTABLE
Statuscode(406)indicatingthattheresourceidentifiedbytherequestisonlycapable
ofgeneratingresponseentitieswhichhavecontentcharacteristicsnotacceptable
accordingtotheacceptheaderssentintherequest
SC_NOT_FOUND Statuscode(404)indicatingthattherequestedresourceisnotavailable
SC_NOT_IMPLEMENTED
Statuscode(501)indicatingtheHTTPserverdoesnotsupportthefunctionalityneeded
tofulfilltherequest
SC_NOT_MODIFIED
Statuscode(304)indicatingthataconditionalGEToperationfoundthattheresource
wasavailableandnotmodified
SC_OK Statuscode(200)indicatingtherequestsucceedednormally
SC_PARTIAL_CONTENT
Statuscode(206)indicatingthattheserverhasfulfilledthepartialGETrequestforthe
resource
SC_PAYMENT_REQUIRED Statuscode(402)reservedforfutureuse
SC_PRECONDITION_FAILED
Statuscode(412)indicatingthatthepreconditiongiveninoneormoreoftherequest
headerfieldsevaluatedtofalsewhenitwastestedontheserver
SC_PROXY_AUTHENTICATION_REQUIRED Statuscode(407)indicatingthattheclientMUSTfirstauthenticateitselfwiththeproxy
SC_REQUEST_ENTITY_TOO_LARGE
Statuscode(413)indicatingthattheserverisrefusingtoprocesstherequestbecause
therequestentityislargerthantheserveriswillingorabletoprocess
SC_REQUEST_TIMEOUT
Statuscode(408)indicatingthattheclientdidnotproducearequestwithinthetimethat
theserverwaspreparedtowait
SC_REQUEST_URI_TOO_LONG
Statuscode(414)indicatingthattheserverisrefusingtoservicetherequestbecause
theRequestURIislongerthantheserveriswillingtointerpret
SC_REQUESTED_RANGE_NOT_SATISFIABLEStatuscode(416)indicatingthattheservercannotservetherequestedbyterange
SC_RESET_CONTENT
Statuscode(205)indicatingthattheagentSHOULDresetthedocumentviewwhich
causedtherequesttobesent
SC_SEE_OTHER
Statuscode(303)indicatingthattheresponsetotherequestcanbefoundundera
differentURI
SC_SERVICE_UNAVAILABLE
Statuscode(503)indicatingthattheHTTPserveristemporarilyoverloaded,andunable
tohandletherequest
SC_SWITCHING_PROTOCOLS
Statuscode(101)indicatingtheserverisswitchingprotocolsaccordingtoUpgrade
header
SC_TEMPORARY_REDIRECT
Statuscode(307)indicatingthattherequestedresourceresidestemporarilyundera
differentURI
SC_UNAUTHORIZED Statuscode(401)indicatingthattherequestrequiresHTTPauthentication
SC_UNSUPPORTED_MEDIA_TYPE
Statuscode(415)indicatingthattheserverisrefusingtoservicetherequestbecause
theentityoftherequestisinaformatnotsupportedbytherequestedresourceforthe
requestedmethod
SC_USE_PROXY
Statuscode(305)indicatingthattherequestedresourceMUSTbeaccessedthrough
theproxygivenbytheLocationfield
RelatedPosts
HowdoIsendacookieinServlet?
HowdoIgetclientIPandhostnameinServlet?
HowdoIreadcookieinServlet?
HowdoIgetservletrequestURLinformation?
HowdoIreadservletinitparameter?
HowdoIgetservletrequestheadersinformation?
HowdoIdeleteacookieinServlet?
Filedin:Servlet
AboutWayanSaryada
Iamaprogrammer,arunner,anopenwaterdiverandcurrentlylivingintheislandofBali,Indonesia.
ViewallpostsbyWayanSaryada
LeaveaReply
Name(Required)
Mail(willnotbepublished)(Required)
Website
WorkfromHome
RecentProjects
Findmoreprojects
Poweredby
Pages RecentPosts RecentComments JavaResources
AffiliateLinks
2014JavaExamples.Allrightsreserved.
Find us on Facebook
Learn by Examples
119 people like Learn by Examples.
Facebook social plugin
Like Like
$30250
View
NeedaClient/Server(MySQL)studentrecord
application...
$30250
View
SimpleJavaProgrammingofWhitepaperScript
/Algorithm(Image/Video)(URLfixed!)...
$30250
View
AndroidandIOSforexmarginapp
android,ipad,iphone,java,mobilephone,app,...
PostaProject
About
Bookstore
HowdoIcreateasimplemail
clientprograminSwing?
Whatarethesystem
propertiesusedforsending
email?
HowdoIsendanHTML
email?
HowdoIreadlastncharacters
fromafile?
JavaSEInstallationTutorial
PierreonHowdoIsendemail
usingGmailviaTLS?
PreethionHowdoImove
focusfromJTextAreausing
TABkey?
AmitonHowdoIgetoperating
systemtemporarydirectory/
folder?
SrinonHowtomonitorfileor
directorychanges?
SrinonHowtomonitorfileor
directorychanges?
JavaLanguageSpecification
JavaSETechnicalDocumentation
JavaTutorials
JavaEETechnicalDocumentation
JavaEE7Tutorials
ShopTechTitlesonoreilly.com
50%offhostingplansfromGoDaddy!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.kodejava.example.servlet;
importjavax.servlet.ServletException;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importjava.io.IOException;
public class ResponseStatus extends HttpServlet {
protected void doGet(HttpServletRequestrequest,
HttpServletResponseresponse) throwsServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequestrequest,
HttpServletResponseresponse) throwsServletException, IOException {
//
//AllresponsestatusisdefinedintheHttpServletResponseclass.We
//canthenusetheseconstantsvaluetoreturnprocessstatustothe
//browser.
//
response.setContentType("text/html");
//
//LetsaythisservletonlyhandlerequestforpagenameinputForm.So
//whenuserrequestforotherpagenameerrorpagenotfound404will
//bereturned,otherwiseitwillbe200whichmeanOK.
//
String page = request.getParameter("page");
if (page != null && page.equals("inputForm")) {
response.setStatus(response.SC_OK);
} else {
response.sendError(response.SC_NOT_FOUND, "Therequestedpage["
+ page + "]notfound.");
}
}
}
About Bookstore
Home 1.JavaSEAPI 2.JavaEEAPI 3.Frameworks 4.OtherLibraries 5.DesignPatterns 6.IDE/Tools
Generated with www.html-to-pdf.net Page 3 / 3

You might also like