|
Create service responding to http request:
Secondly,on the server-side,within Java web application,we use one Java Servlet as service running on web server. This servlet is to validate user name. It has the doGet method to service http GET method:
public void doGet(HttpServletRequest oRequest,HttpServletResponse oResponse) throws IOException,ServerException { String strUserName = oRequest.getParameter(“UserName”);
oResponse.setContentType("text/xml"); oResponse.setHeader("Cache-Control","no-cache"); if (“VisualBuilder”. indexOf(strUserName) == 0) { if (“VisualBuilder”.equals(strUserName)) { oResponse.getWriter().write(“Valid”); } else { oResponse.getWriter().write(“Continue”); } } else { oResponse.getWriter().write(“Invalid”); } }
The doGet checks user name posted by the client. If the is used name as a beginning part of “VisualBuilder”,the value of text response will be “Continue”,this means user is typing correctly. If the name is equal to “VisualBuilder”,the response will be “Valid”. However,in other cases,the response will be “Invalid”. At the last,the doGet sends back this response to client.
|