Forward with servlets

Im using tomcat 4.06 and i have some problems with servlets and forwarding:
This is my servlet:
import java.io.PrintWriter;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
public class NTenant extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String email = request.getParameter("tenant");
//insert new tenant into database.
System.out.println("Redirigiendo");
ServletContext sc = getServletConfig().getServletContext();
RequestDispatcher rdNext = sc.getRequestDispatcher("/tenantForm.html");
rdNext.forward(request, response);
System.out.println("Redirigido");
I get this error:
type Status report
message Servlet invoker is currently unavailable
description The requested service (Servlet invoker is currently unavailable) is not currently available.
This is my dir structure:
webapps\form\NewTenant.html
webapps\form\tenantForm.html
webapps\form\WEB-INF\web.xml
webapps\form\WEB-INF\classes\NTenant.class
webapps\form\WEB-INF\classes\TenantServlet.class
The problem is that i cannot find my html, what must i write here? sc.getRequestDispatcher("/tenantForm.html"); <-----
Thank you very much

I heve tried with "../tenantForm.html"
java.lang.IllegalArgumentException: Path ../tenantForm.html does not start with a "/" character
     at org.apache.catalina.core.ApplicationContext.getRequestDispatcher(ApplicationContext.java:572)
     at org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(ApplicationContextFacade.java:174)
     at NTenant.doPost(NTenant.java:19)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
Now Im trying with:
RequestDispatcher rdNext = sc.getRequestDispatcher "/../tenantForm.html");
And I got:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
     at NTenant.doPost(NTenant.java:20)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:465)
     at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
     at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
     at java.lang.Thread.run(Thread.java:536)
Any other idea?

Similar Messages

  • Bean value forward to servlet

    Hi all,
    i have bean package cedars;
    import java.util.Hashtable;
    import java.util.*;
    public class FormBean {
          private String name = null;
          private String stuNumber = null;
          private String facultyName= null;
          private String quesOne = null;
          private String quesTwo = null;
          private String quesThree = null;
          private String quesFour= null;
          private String quesFive= null;
          private String quesSix= null;
          private String quesSeven= null;
          private String quesEight= null;
          private String quesNine= null;
          private String quesTen= null;
          private String quesEleven= null;
          private String quesTwelve= null;
          private String quesThirteen= null;
          private String quesFourteen= null;
          private String quesFifteen= null;
          private String quesSixteen= null;
          private String quesSeventeen = null;     
          private String quesEighteen=null;
          private String quesNineteen=null;
          private String quesTwenty=null;
          private String quesTwentyOne=null;
          private Hashtable errors = new Hashtable();
          public boolean validate() {
                  boolean allOk=true;
                  if (stuNumber.equals("")|| stuNumber.length() !=10) {
                      errors.put("stuNumber","Please enter a valid student Number");
                      stuNumber="";
                      allOk=false;
                    } else {
                        try {
                            int x = Integer.parseInt(stuNumber);
                          } catch (NumberFormatException e) {
                            errors.put("stuNumber","Please enter a valid student Number");
                            stuNumber="";
                            allOk=false;
                    }//else
                  return allOk;        
          public String getErrorMsg(String s) {
                  String errorMsg =(String)errors.get(s.trim());
                  return (errorMsg == null) ? "":errorMsg;
         public FormBean () {
              again(); 
         /* Name */
           public String getName() {
             return (this.name);
           public void setName(String name) {
             this.name = name;
           /* Student number */
           public String getStuNumber(){
             return (this.stuNumber);
           public void setStuNumber(String stuNumber){
             this.stuNumber = stuNumber;
           /* gender */
           private String gender= null;
           public String getGender(){
             return (this.gender);
           public void setGender(String gender) {
             this.gender = gender;
           /*college*/
           public String getFacultyName(){
             return (this. facultyName);
           public void setFacultyName(String  facultyName){
             this. facultyName=facultyName;
           /*degree*/
           String degree=null;
           public String getDegree() {
                  return (this.degree);
           public void setDegree(String degree){
             this.degree =degree;
           /* year */
           private String year = null;
           public String getYear() {
             return (this.year);
           public void setYear(String year){
             this.year = year;
           /*question one */
           public String getQuesOne() {
             return (this.quesOne);
           public void setQuesOne(String quesOne){
             this.quesOne = quesOne;
           /*question two */
           public String getQuesTwo() {
             return (this.quesTwo);
           public void setQuesTwo(String quesTwo){
             this.quesTwo = quesTwo;
           /*question Three */
           public void setQuesThree(String quesThree){
             this.quesThree = quesThree;
           /*question four */
           public String getQuesFour() {
             return (this.quesFour);
           public void setQuesFour(String quesFour){
             this.quesFour = quesFour;
           /*question five */
           public String getQuesFive() {
             return (this.quesFive);
           public void setQuesFive(String quesFive){
             this.quesFive = quesFive;
           /*question six */
           public String getQuesSix() {
             return (this.quesSix);
           public void setQuesSix(String quesSix){
             this.quesSix =quesSix;
           /*question seven */
           public String getQuesSeven(){
             return (this.quesSeven);
           public void setQuesSeven(String quesSeven){
             this.quesSeven =quesSeven;
           /*question Eight */
           public String getQuesEight() {
             return (this.quesEight);
           public void setQuesEight(String quesEight){
             this.quesEight =quesEight;
           /*question Nine */
           public String getQuesNine() {
             return (this.quesNine);
           public void setQuesNine(String quesNine) {
             this.quesNine =quesNine;
           /*question Ten */
           public String getQuesTen(){
             return (this.quesTen);
           public void setQuesTen(String quesTen){
             this.quesNine =quesTen;
           /*question Eleven*/
           public String getQuesEleven(){
             return (this.quesEleven);
           public void setQuesEleven(String quesEleven) {
             this.quesEleven =quesEleven;
           /* question Twelve*/
           public String getQuesTwelve(){
             return (this.quesTwelve);
           public void setQuesTwelve(String quesTwelve) {
             this.quesTwelve =quesTwelve;
           /* question Thirteen**/
           public String getQuesThirteen() {
             return (this.quesThirteen);
           public void setQuesThirteen(String quesThirteen) {
             this.quesThirteen =quesThirteen;
           /*question Fourteen*/
           public String getQuesFourteen() {
             return (this.quesFourteen);
           public void setQuesFourteen(String quesFourteen) {
             this.quesFourteen =quesFourteen;
           /* question Fifteen*/
           public String getQuesFifteen(){
             return (this.quesFifteen);
           public void setQuesFifteen(String quesFifteen) {
             this.quesFifteen =quesFifteen;
          /* question Sisteen*/
           public String getQuesSixteen(){
             return (this.quesSixteen);
           public void setQuesSixteen(String quesSixteen) {
             this.quesSixteen =quesSixteen;
          /* question Seventeen */
           public String getQuesSeventeen (){
             return (this.quesSeventeen );
           public void setQuesSeventeen (String quesSeventeen ) {
             this.quesSeventeen=quesSeventeen ;
           /* question Eighteen*/
           public String getQuesThree(){
             return (this.quesThree);
         public String getQuesEighteen (){
                  return (this.quesEighteen );
         public void setQuesEighteen(String quesEighteen ){
                  this.quesEighteen =quesEighteen ;
           /*question Nineteen*/
         public String getQuesNineteen(){
             return (this.quesNineteen );
          public void setQuesNineteen(String quesNineteen ){
               this.quesNineteen =quesNineteen ;
         /*Twenty*/
      public String getQuesTwenty(){
         return (this.quesTwenty );
      public void setQuesTwenty(String quesTwenty ){
         this.quesTwenty =quesTwenty ;
         /*Twenty-One*/
    public String getQuesTwentyOne(){
    return (this.quesTwentyOne );
    public void setQuesTwentyOne(String quesTwentyOne ) {
          this.quesTwentyOne =quesTwentyOne ;     }
    public void setErrors(String key, String msg) {
             errors.put(key,msg);
           public void again(){                               
                  setName("");
                  setStuNumber("");
                  setGender("");
                  setFacultyName("");
                  setDegree("");            
                  setYear("");           
                  setQuesOne("");
                  setQuesTwo("");
                  setQuesThree("");
                  setQuesFour("");
                  setQuesFive("");
                  setQuesSix("");
                  setQuesSeven("");
                  setQuesEight("");
                  setQuesNine("");
                  setQuesTen("");
                  setQuesEleven("");
                  setQuesTwelve("");
                  setQuesThirteen("");
                  setQuesFourteen("");
                  setQuesFifteen("");     
                  setQuesSixteen("");
                  setQuesSeventeen("");
                  setQuesEighteen("");
                  setQuesNineteen("");
                  setQuesTwenty("");
                  setQuesTwentyOne("");
    }and process.jsp
    %@ page import="java.util.*" %>
    <html>
      <head>
    <jsp:useBean id="formHandler" class="cedars.FormBean" scope="request">
    <jsp:setProperty name="formHandler" property="*"/>
    </jsp:useBean>
    <%
       if (formHandler.validate()) {%>
    <jsp:forward page="/servlet/Insert"/>
    <% } else { %>
    <jsp:forward page="/resubmit.jsp"/>
    <% } %>
    </body>
    </html>row now the forward to resubmit.jsp is work , but forward to <jsp:forward page="/servlet/Insert"/>
    is not work , why?
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import javax.sql.*;
    import pool.ConnectionPool;
    public class Insert extends HttpServlet {   
        Connection conn = null;
        Statement stmt = null;
         ResultSet rs = null;
         PreparedStatement ps = null;
         ConnectionPool connectionPool = null;
       * We want to initialized the JDBC connections here
        public void init()
                 String jdbcDriver = "com.mysql.jdbc.Driver";
                 String dbURL ="jdbc:mysql://localhost/survey?";
                 try
                 //instantiate the connection pool object by passing the
                 //jdbc driver, database URL, username, and password
                 connectionPool = new ConnectionPool(jdbcDriver, dbURL,
                 "root","mysql");
                 //specify the initial number of connections to establish
                 connectionPool.setInitialConnections(5);
                 //specify number of incremental connections to create if
                 //pool is exhausted of available connections
                 connectionPool.setIncrementalConnections(5);
                 //specify absolute maximum number of connections to create
                 connectionPool.setMaxConnections(20);
                 connectionPool.createPool(); //create the connection pool
                 catch(Exception e)
                 System.out.println("Error: " + e);
    /** Destroys the servlet.
        public void destroy() {
        public void doGet(
        HttpServletRequest request,
        HttpServletResponse response)
        throws IOException, ServletException {  
           }// end of DoGet
    public void doPost(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {    
         res.setContentType("text/html");
         PrintWriter out = res.getWriter(); 
       try {        
        //Get the incoming data parameters from the client         
               String  name=req.getParameter("name");
               String  stuNumber=req.getParameter("stuNumber");
               String  gender=req.getParameter("gender");
               String  facultName=req.getParameter("facultyName");
               String  degree=req.getParameter("degree");          
               String  year=req.getParameter("year");        
               String  quesOne=req.getParameter("quesOne");
               String  quesTwo=req.getParameter("quesTwo");
               String  quesThree=req.getParameter("quesThree");
               String  quesFour=req.getParameter("quesFour");
               String  quesFive=req.getParameter("quesFive");
               String  quesSix=req.getParameter("quesSix");
               String  quesSeven=req.getParameter("quesSeven");
               String  quesEight=req.getParameter("quesEight");
               String  quesNine=req.getParameter("quesNine");
               String  quesTen=req.getParameter("quesTen");
               String  quesEleven=req.getParameter("quesEleven");
               String  quesTwelve=req.getParameter("quesTwelve");
               String  quesThirteen=req.getParameter("quesThirteen");
               String  quesFourteen=req.getParameter("quesFourteen");
               String  quesFifteen=req.getParameter("quesFifteen");
               String  quesSixteen=req.getParameter("quesSixteen");
               String  quesSeventeen=req.getParameter("quesSeventeen");
               String  quesEighteen=req.getParameter("quesNineteen");
               String  quesNineteen=req.getParameter("quesNineteen");
               String  quesTwenty=req.getParameter("quesTwenty");
               String  quesTwentyOne=req.getParameter("quesTwentyOne");
               String ErrMsg="";
               String found="";
               HttpSession userSession = req.getSession(true);   
               HttpSession session=req.getSession();
               for (int i=0; i<stuNumber.length(); i++){              
                    char ch=stuNumber.charAt(i);
                   if (Character.isLetter(ch)){
                     found =found +ch;}
                * check the empty fields
                       if (stuNumber.equals("") ||                    
                                ((found.length()>=1 ))||                         
                                (stuNumber.length()!=10))
                           out.println("<html>");                        
                           out.println("<body bgcolor=\"#FFFFFF\">");
                            out.println("<center>");
                           out.println("<strong> Valid Studend number is require!<strong>");
                           out.println("</center>");
                           out.println("</body>");                        
                           out.println("</html>");
                           out.close();
                       Integer q1=0, q2=0, q3=0, q4=0, q5=0, q6=0, q7=0, q8=0,q9=0,q10=0;
                       Integer q11=0, q12=0, q13=0, q14=0, q15=0, q16=0, q17=0, q18=0, q19=0, q20=0,q21=0;
                         q1 = Integer.valueOf(quesOne);
                         q2 = Integer.valueOf(quesTwo);
                         q3 = Integer.valueOf(quesThree);
                         q4 = Integer.valueOf(quesFour);
                         q5 = Integer.valueOf(quesFive);
                         q6 = Integer.valueOf(quesSix);
                         q7 = Integer.valueOf(quesSeven);
                         q8 = Integer.valueOf(quesEight);
                         q9 = Integer.valueOf(quesNine);
                          q10 = Integer.valueOf(quesTen);
                          q11 = Integer.valueOf(quesEleven);
                          q12 = Integer.valueOf(quesTwelve);
                          q13 = Integer.valueOf(quesThirteen);
                          q14 = Integer.valueOf(quesFourteen);
                           q15 = Integer.valueOf(quesFifteen);
                           q16 = Integer.valueOf(quesSixteen);
                            q17 = Integer.valueOf(quesSeventeen);
                             q18 = Integer.valueOf(quesEighteen);
                             q19 = Integer.valueOf(quesNineteen);
                             q20 = Integer.valueOf(quesTwenty);
                              q21 = Integer.valueOf(quesTwentyOne);
                       Integer total=0;
                       total=q1+q2+q3+q4+q5+q6+q7+q8+q9+q10+q11+q12+q13+q14+q15+q16+q17+q18+q19+q20+q21;
                       /*if form is valid, catch the session*/
                         userSession.setAttribute("stuNumber",stuNumber );
                           userSession.setAttribute("quesOne",quesOne); 
                           userSession.setAttribute("quesTwo",quesTwo); 
                           userSession.setAttribute("quesThree",quesThree); 
                           userSession.setAttribute("quesFour",quesFour); 
                           userSession.setAttribute("quesFive",quesFive); 
                           userSession.setAttribute("quesSix", quesSix); 
                           userSession.setAttribute("quesSeven",quesSeven); 
                           userSession.setAttribute("quesEight",quesEight); 
                           userSession.setAttribute("quesNine",quesNine); 
                           userSession.setAttribute("quesTen",quesTen); 
                           userSession.setAttribute("quesTwelve", quesTwelve);
                           userSession.setAttribute("quesEleven",  quesEleven);
                           userSession.setAttribute("quesThirteen", quesThirteen);
                           userSession.setAttribute("quesFourteen", quesFourteen);
                           userSession.setAttribute("quesFifteen",   quesFifteen);              
                          userSession.setAttribute("quesSixteen",  quesSixteen);             
                          userSession.setAttribute("quesSeventeen",quesSeventeen);
                          userSession.setAttribute("quesEighteen", quesEighteen);
                          userSession.setAttribute("quesNineteen",quesNineteen);
                          userSession.setAttribute("quesTwenty",quesTwenty);
                           userSession.setAttribute("quesTwentyOne",quesTwentyOne);
                           userSession.setAttribute("total",total);
                            RequestDispatcher disp;
                            disp = getServletContext().getRequestDispatcher("/confirmation.jsp");
                            disp.forward(req, res);      
                          //get free connection from pool
                            conn =connectionPool.getConnection();      
                //select a database
               // conn.setCatalog("survey");
                /* add this part*/
                stmt = conn.createStatement();
                rs = stmt.executeQuery("SELECT*  FROM survey where stuNumber='"+stuNumber+"'");
                    int count =0;//how many rows we can find.
                    while (rs.next()){
                        count++;
                    connectionPool.returnConnection(conn);
                 if(count<1){                       
                          conn.setAutoCommit(false);
                        String  sql="insert into survey(name, stuNumber, gender,facultyName,degree, year, quesOne, quesTwo, quesThree, quesFour, quesFive, quesSix,quesSeven, quesEight, quesNine,quesTen,quesEleven, quesTwelve, quesThirteen, quesFourteen,quesFifteen, quesSixteen, quesSeventeen, quesEighteen, quesNineteen, quesTwenty, quesTwentyOne)";
                                             sql+="value(?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                              ps = conn.prepareStatement(sql);
                              stmt = conn.createStatement();
                               ps.setString(1, name);
                              ps.setString(2, stuNumber);
                              ps.setString(3, gender);
                              ps.setString(4, facultName);
                              ps.setString(5, degree);
                              ps.setString(6, year);
                              ps.setString(7, quesOne);
                              ps.setString(8, quesTwo);
                              ps.setString(9, quesThree);
                              ps.setString(10, quesFour);
                              ps.setString(11, quesFive);
                              ps.setString(12, quesSix);
                              ps.setString(13, quesSeven);
                              ps.setString(14, quesEight);
                              ps.setString(15, quesNine);
                              ps.setString(16, quesTen);
                              ps.setString(17, quesEleven);
                              ps.setString(18, quesTwelve);
                              ps.setString(19, quesThirteen);
                              ps.setString(20, quesFourteen);
                              ps.setString(21, quesFifteen);
                              ps.setString(22, quesSixteen);
                              ps.setString(23, quesSeventeen);
                              ps.setString(24, quesEighteen);
                              ps.setString(25, quesNineteen);
                              ps.setString(26, quesTwenty);
                              ps.setString(27, quesTwentyOne);
                              ps.executeUpdate();                   
                         conn.commit();
                      conn.setAutoCommit(true);   
                      connectionPool.returnConnection(conn);
                 /* doing the update*/
                 else{
                      conn.setAutoCommit(false);
                      String sql2 = "UPDATE survey set name=?";
                        sql2+= ", gender=?,facultyName=?,degree=?, year=?, quesOne=?, questwo=?, quesThree=?, quesFour=?, quesFive=?, quesSix=?,";
                        sql2+= "quesSeven=?,quesEight=?, quesNine=?, quesTen=?,quesEleven=?, quesTwelve=?, quesThirteen=?, quesFourteen=?";
                        sql2+=",quesFifteen=?, quesSixteen=?, quesSeventeen=?, quesEighteen=?, quesNineteen=?, quesTwenty=?, quesTwentyOne=?";
                        sql2+="WHERE stuNumber=?";
                        ps = conn.prepareStatement(sql2);
                        stmt = conn.createStatement();
                         ps.setString(1, name);                    
                          ps.setString(2, gender);
                          ps.setString(3, facultName);
                          ps.setString(4, degree);
                          ps.setString(5, year);
                          ps.setString(6, quesOne);
                          ps.setString(7, quesTwo);
                          ps.setString(8, quesThree);
                          ps.setString(9, quesFour);
                          ps.setString(10, quesFive);
                          ps.setString(11, quesSix);
                          ps.setString(12, quesSeven);
                          ps.setString(13, quesEight);
                          ps.setString(14, quesNine);
                          ps.setString(15, quesTen);
                          ps.setString(16, quesEleven);
                          ps.setString(17, quesTwelve);
                          ps.setString(18, quesThirteen);
                          ps.setString(19, quesFourteen);
                          ps.setString(20, quesFifteen);
                          ps.setString(21, quesSixteen);
                          ps.setString(22, quesSeventeen);
                          ps.setString(23, quesEighteen);
                          ps.setString(24, quesNineteen);
                          ps.setString(25, quesTwenty);
                          ps.setString(26, quesTwentyOne);
                          ps.setString(27,  stuNumber);
                          ps.executeUpdate();                   
                   conn.commit();
                 conn.setAutoCommit(true);   
                 connectionPool.returnConnection(conn);
        }catch (SQLException e) {
              throw new ServletException(e);
         finally {
              try {
                   if(rs != null)
                        rs.close();
                   if(stmt != null)
                        stmt.close();
                   if(ps != null)
                        ps.close();
                   if(conn != null)
                        conn.close();
                   connectionPool.returnConnection(conn);
              } catch (SQLException e) {}
    } // end doPost
    public String getServletInfo()
        return "A Simple Servlet";
    }// end of ContrInsert

    The way to do this with a JSP is use an HTML Form tag to pass all the information on to a new page, and save the new info while creating this new page

  • Communicate with servlet after using Java Web Start?

    Is it possible to communicate with servlet to get data back and forth
    after using Web Start to download the client application?
    The demos come with Java Web Start are applications which are
    standalone, don't need communicate with the servlet on Web server
    after being launched. I am wondering if it is possible, and how (HTTP
    & JAX-RPC)?
    Thanx in advance.

    I've done this using HTTP. I get the server and port from the codebase:
    BasicService bs = null;
    try {
    bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
    String codeBase = bs.getCodeBase().toString();
    and use the java.net.HttpURLConnection and java.net.URL classes to send HTTP parameter values to the servlet and to receive results from the HttpURLConnection's input stream.

  • Displaying *.pdf file on browser with servlet

    hi all
    this RAMESH,struggling to display a pdf file on browser from a remote mechine
    earlier i tried with servlet
    response.setContentenType("application/pdf")
    out.println();
    by this i am getting only some data as below
    endobj
    4 0 obj
    <<
    /ProcSet [ /PDF /Text /ImageB ]
    /Font << /Fo0 21 0 R /Fo12 24 0 R /Fo13 27 0 R /Fo16 30 0 R /Fo18 33 0 R /Fo19 36 0 R >>
    >>
    endobj
    For this purpose i have gone thru www.lowagie.com
    and gone thru all examples but i am not getting how to display on browser or at least awt frame
    please requesting all for suggest me some way
    tanks all
    -Ramesh

    are you trying to
    a) create a PDF dynamically
    b) send an existing PDF

  • How to use JNI with Servlets

    Hi
    i was trying to do some example with JNI. I can use JNI with standalone Java application but I just cannot figure out how I can use JNI with Servlet.
    Can some one show me a sample code using JNI with Servlets.
    thanks very much

    hi,
    I am also facing the same problem,
    when I am using JNI with stand alone application it works fine but when i tried to use it with a servlet It gives unsatisfied linker error
    stack: java.lang.UnsatisfiedLinkError: createSocket
         at RelayConnector.createSocket(Native Method)
         at RelayServlet.doGet(RelayServlet.java:70)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:891)
         at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:458)
    It seems i have to do some path settings in my iplenet web server.
    If some one have faced the problem i would be glad to know the solution for this, i am literally bugged up,....

  • Problem with Servlets

    Hi,
    I am Tejas , a newbie with servlets. Now, I have a servlet which contains a Javascript method. On clicking a link , the Javascript method is called.
    But however, I find that there is some trouble. I created a class called MainFrames.java, the object of which I am instantiating in the Javascript method.
    But this code doesnt work properly. I have given the snippet below
    out.println("<script type='text/javascript'>");
    out.println("function threader()");
    out.println("{");
    out.println("alert('Inside Threader');");
    out.println("<%@ page import=\"XcForm.MainFrames\"%>"); //I have a hunch that this statement is the problem
    out.println("<%");
    out.println("MainFrames mainframes = new MainFrames();"); //without the import statement above, the MainFrames.java class is not being recognised
    out.println("%>");
    out.println("}");
    out.println("</script>");
    Thanks in advance,
    Tejas

    Do not put presentation code in servlets. Put them in JSPs. And mixing serverside code (scriptlets) and clientside code (javascript) this way is indeed not going to work. That code will certainly not be executed in the order as you write. Serverside code is executed at the server and is finished when the response is completed. So any serverside code inside clientside code is alreay executed. Clientside code is executed at the client and will only execute when the response is completed (onload, etc) or when the client invokes it (onclick, onsubmit, etc). Further on, do not put business code in presentation code. Put them in servlets.

  • JSF 1.2 with SERVLET 2.3

    Hi, i've download the latest JSF 1.2 RI but i can't see any page as i get the following error:
    ava.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getContentType()Ljava/lang/String;
    at com.sun.faces.context.ExternalContextImpl.getResponseContentType(ExternalContextImpl.java:277)
    at com.sun.faces.renderkit.RenderKitImpl.createResponseWriter(RenderKitImpl.java:167)
    at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:131)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    The getContentType method that the exception describes is only available in servlet 2.4 but i'm using a servlet 2.3 only container. Can i use JSF 1.2 with servlet 2.3 ?
    Thanks

    I'm 90% sure that you cannot. JSF 1.2 is intended to be part of Java EE 5.0. Since Servlets 2.3 are part of J2EE 1.3, I don't think that it will work.
    Adam

  • Some problems with servlet.jar and tomcat 4.1.27

    Hello everybody,
    I used to work with tomcat 3.3.1 and i've decided to use tomcat 4.1.27 now. The manual explains that we have to change de version of servlet.jar, it's done with servlet-2.3.jar but on tomcat starting i have this message:
    jar not loaded. See servlet spec [...]. Offending class: javax/servlet/Servlet.class
    what can i do, i've red all de documentation and i think all versions a OK??
    thanks per advance
    antoine

    I am running Tomcat 4.1.18, so your configuration may be slightly different. I found the Servlet.class file you are missing residing in the Tomcat/common/lib directory in the Servlet.jar file. Check your path and also make sure your Servlet.jar file contains the missing class.

  • FMJ2 - Carry forward with budget Line

    Hello,
    I have done a carry forward FMJ2 and everything works perfectly. However the client let me know that they also want the budget line associated to the commitments to be carry forwarded.
    When I try that, the system gives me error FMAVC005.
    In "Define basic stting for carry forward" I have "Carry forward with document chain".
    In "Enter default settings" I have flaged "Carry forward budget for commitement allowed" and also the other 2 (Commitemnt and residual).
    Any idea about this topic.
    Please let me know.
    Regards,

    Hello,
    Avalability control is activated and I ma working with BCS Budget.
    In 2013 I have introduce my budget FMBB (Budget line). Then I have created a reserve agaisnt this budget line.
    When I try to do the carry forward the budget line is not carry forward and so the reserve in 2014 is trying to consume a budget line that do not exist.
    Please find a document with the images of the customizng and the 4th one with the result of the budget in 2014 but without the availability control (I get a negative ammount).
    Regards,
    Daniel

  • Port Forwarding with Port Translation RV042, RV016, RV082

    This is a feature request for the Linksys RV series Routers.  Currently, it appears that the Cisco/Linksys RV042, RV082, and RV016 only support port forwarding and 1-to-1 Nat.  One item that I find very helpful with customers is port forwarding with port translation.  I am requesting that this feature be included with a future firmware relase for these RV series routers.
    Here is an example of the request.
    Take an incoming service request on a TCP or UDP destination port and forward it to an internal IP on a different TCP or UDP port.  For example, customer A wants to allow different machines on the internal network to receive Windows RDP connections inbound.  To make PC maintenance identical between the internal machines, the customer does not want to change the listening port for RDP on the individual PC workstations through the Windows Registry.  The customer also does not want to dedicate separate IP's to each machine in a 1-to-1 NAT setup.  The only option is to have remote connections to each of these PC's to use a different destination port.  So, for example, PC one could be reached on TCP port 5151, PC two on TCP port 5152, and PC three on port 5153.  This requres a firewall that is able to translate each of these connection requests to a different internal IP on the default RDP port (TCP 3389).  So, the following setup is required:
    Port Forwarding with Port Translation:
    Router External IP on TCP port 5151 ---> forwarded to PC One's internal IP on TCP 3389
    Router External IP on TCP port 5152 ---> forwarded to PC Two's internal IP on TCP 3389
    Router External IP on TCP port 5153 ---> forwarded to PC Three's internal IP on TCP 3389
    There are several comparable "small business" class router competitors to the RV042, RV082, and RV016 that will perform this port forwarding with port translation process without incident.  Unfortunately, these Cisco/Linksys small business routers will not accomplish this task currently.
    Please implement this feature in a future firmware release.
    Thanks!

    Excellent.  I see this now.  None of our customers actually use the UPNP feature, so we never realized that Port Forwarding with Port Translation features existed on this page along with the ability to enable or disable UPNP.
    Perhaps, in the future, this functionality could be moved to and incorporated into the port forwarding page which seems to be a more logical location.
    In either case I'm very happy to know that this feature is available on the RV's.
    Thanks for your assistance.

  • Communicating with Servlets....

    hi!
    Wat are all the different ways in which the JSP used to communicate with Servlet?
    Thanx,
    Rgds,
    Sasi

    Jsp page communication with Servlets....
    web.xml -- Servlets loaded during application startup
    struts config -- Servlet mapping (w.r.t struts).
    and u can import servlets in jsp and can use it... there are so many possible ways of using servlets coz jsp pages inturn convert into servlets and got executed.....

  • Dialogs with servlets

    Hi
    Does anyone know how to use dialogs with servlets? I'd like to show a confirm dialog on the client machine. My first idea was to use JOptionPane.showConfirmDialog as such in the servlet, but then of course de dialog pops-up on the server side, and not on client side.
    Many thanks for the help,
    Nic

    You need to use javascript to confirm, ask questions, etc...
    You can see :
    http://www.webreference.com/programming/javascript/confirm/
    Or
    http://www.bodo.com/javacool.htm
    Fred

  • Swings with servlets

    Hi,
    how we can use swings with servlets or jsps.
    or
    how we can display the browser in the swings.
    please give me a valid answer with examples.

    Hi,
    Your question is not clear... are you trying to display HTML using swing components or are you trying to use swing in a server-side application?
    Some Swing components (e.g. JLabel) natively support simple html, so:
    JLabel lbl = new JLabel("<html>hello <b>world</b></html>");would result in a JLabel that looks with the word "world" in bold. If you need also frames, css and javascript support - you'll need to reach for a 3^rd^ party library, I'm afraid.
    As for using swing in servers, look at this article:
    http://today.java.net/pub/a/today/2006/04/20/bringing-swing-to-the-web.html
    If you meant neither, please explain more.
    Hope this helps, though.
    Michael Bar-Sinai

  • Port Forwarding with Verizon-Br​anded Action GT704-WG

    I am new to the forums, and I am already overjoyed with the 30 minutes I spent figuring out that the login mechanism does not even work with browsers other than IE7/8.  Lots of fun to start.
    I live in a residential building with the residential High Speed Internet Plan.  I assume this is the case because it is a DSL line and they are not using business grade, or I do not think I would be having these problems.
    I have spent many hours trying to figure out how to port forward with the above-mentioned router/modem/gateway/**bleep** extraordinnaire.  I am in IT professionally, and I am tired of feeling **bleep**.  I called Verizon tech, but they were very unhelpful unless I pay for a premium tech service to figure out port forwarding problems.  And yes, I have read the info on port-forward.com numerous times for this device.
    Essentially, I want to forward an arbitrary port, let's say 6336, to a server running Ubuntu 9.10.  I have put this computer in the DMZ using the web interface.  I have also set up a mapping rule to forward 6336 (all three entries pointed to 6336 in the Security/Applications/Forwarding section, following docs on port-forward.com for this specific model AND Verizon's own documentation).  Occassionally, I can see the service is viewable from the likes of canyouseeme.org.  Nonetheless, I cannot access the port: I get a connection refused error when using ssh on this port.  Yes, I correctly configured ssh on the DMZ server/host to respond to the non-standard 6336 port, and I have tried it with the server's firewall system (ufw/iptables, for the curious) enabled and disabled.  It NEVER works.
    Some posts here have indicated I might need a static IP assignment.  That can be done only client-side (meaning the Ubuntu server in the DMZ), if I understand people saying it is not possible to do static assignments from this **bleep** gateway, so I am not sure if that should matter (I wonder what happens with this **bleep** when two computers try to demand the same static IP; dare I guess that he asks first wins?).  I cannot recall if I have uPnP enabled or disabled as I am at the office right now, but I believe it is off.  Not sure if this matters either.  If I am wrong, I would love if someone could let me know.  I am at a loss and sick of dealing with such a simple problem.  I would really appreciate the help. 
    Solved!
    Go to Solution.

    Ok.
    #1 On your computer setup a Static IP.
    This means following the directions at http://www.cyberciti.biz/tips/howto-ubuntu-linux-c​onvert-dhcp-network-configuration-to-static-ip-con​...
    #2 The Static IP must be outside of that DHCP range of the router. So, this means your IP has be above 1 but below 64.
    #3 In the router forward to the IP Address that you setup on the computer.
    OR if the router can give the computer the same IP Address each time, you could do that.
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

  • [Help] To prevent timeout error of browser in clinet with servlet in server

    Hi all,
    If a browser (for example, Internet Explorer) do not get any response from a server for more than sometime (in case of IE, default is 5 min), it will stop waiting and return some timeout error message.
    But I have a servlet, which has a really long-time(at least 10 min) job to do before it could send a response to the browser. So, before the browser in client can get the result, it stops waiting.
    I know I can change the time-out setting of browser in client machines, but there are hundred of thousands.
    So, what I am asking is if it is possible to do it with servlet in server, and how?
    (for example, send something to the client every few minutes, but I do not know how to do it .)
    thanks a lot!

    What you would have to do is set up some sort of 'Buffer' servlet.
    It starts the job in the background, and then returns a page saying job started - client does not time out.
    You would have to start it in a seperate process - probably a new Thread.
    The client would then have to send back requests asking - is it finished yet?
    While the job is not finished the buffer servlet returns a "not yet" message.
    On completion, the job can be sent back to the client.
    Couple of pointers:
    It may be easier to have the background process generate the result to file - then your buffer servlet can just pick up the file when it is completed.
    To get your page to refresh multiple times, you can use javascript: window.setTimeout("[reload page]");
    Good luck,
    evnafets

Maybe you are looking for