RapidSpell Web provides convenient JavaBeans to enable use with Servlets. The Beans,
RapidSpellWebLauncherBean and RapidSpellWebBean mirror the properties of the Tags described in this
guide, and given the ‘single round trip’ nature of RapidSpell Web make adding spell checking to new and
existing Servlets relatively easy.
Page containing the RapidSpellWebLauncher.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import com.keyoti.rapidSpell.web.*;
/** The servlet which will use the launcher button */
public class SpellUser extends HttpServlet{
/**Process a GET request*/
public void doGet(HttpServletRequest request,
HttpServletResponse response){
processRequest(request, response);
}
/**Process a POST request*/
public void doPost(HttpServletRequest request,
HttpServletResponse response){
processRequest(request, response);
}
/** Generic request processor */
protected void processRequest(HttpServletRequest request,
HttpServletResponse response){
try{
PrintWriter pW = response.getWriter();
pW.println(“<html><body><form name="f1"><textarea name=’n1'
cols=50 rows=5></textarea>”);
//Add RapidSpellWebLauncher to page
RapidSpellWebLauncherBean launcher = new
RapidSpellWebLauncherBean();
launcher.setTextComponentName("f1.n1");
launcher.setRapidSpellWebPage("/rsuser/RSWebPopUp");
launcher.writeHtml(pW, request);
pW.println("</form></body></html>");
} catch (IOException e){
//.................
}
}
}
Page containing RapidSpellWeb.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import com.keyoti.rapidSpell.web.*;
/** Note that if the user dictionary is being used this servlet will receive GET
requests aswell as the usual POST requests. */
public class RSWebPopUp extends HttpServlet{
public void doGet(HttpServletRequest request,
HttpServletResponse response){
processRequest(request, response);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response){
processRequest(request, response);
}
protected void processRequest(HttpServletRequest request,
HttpServletResponse response){
try{
PrintWriter pW = response.getWriter();
pW.println("<html><body><center>");
//Add RapidSpellWeb to page
RapidSpellWebBean checker = new RapidSpellWebBean();
checker.writeHtml(pW, request);
pW.println("</center></body></html>");
} catch (IOException e){
//...........
}
}
}
Please consult the Servlet zip file for a demonstration application. The same principle applies to the
RapidSpellWInlineBean.