Java Sample For Server-side validation? - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

oggieone
Posts: 4
Joined: Sun Dec 16, 2007 3:18 am

Java Sample For Server-side validation?

Hi, I was wondering if anyone had a sample of the Server-side validation using java or javascript. I don't get how my remote server hosting the script/servlet? would know where to redirect back to the client machine.
I assume I am missing something on how this works.

Thanks in advance.
oggieone
Posts: 4
Joined: Sun Dec 16, 2007 3:18 am

Never mind...that was simple. In case anyone wants a sample here is the sample code..

public void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
{
log.debug(">>>Registration");
String myResponse = "";
String serialNumber = request.getParameter("sn");
log.debug("serialNumber = " + serialNumber );
if ( !serialNumber.equals("123-456") ){
myResponse = "602\nSerial Number Invalid";
}
else{
myResponse = "601\nVaild Serial Number";
}
log.debug("Returning : " + myResponse );
try{
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/html");
out.println( myResponse );
out.flush();
out.close();
}
catch(Exception e){
log.debug("Registration Error : " + e.toString() );
}
log.debug("<<<Registration");
}

Return to “Common Problems”