Servlet using NES 3.5.1 and WLS 5.1

          Hello All!
          When I send the attached servlet directly to WLS 5.1 as Web-server it works fine.
          But when I use NES 3.5.1 as a Web-Server I receive the message:
          "Your client is not allowed to access the requested object."
          How can I solve this problem?
          Thanks for any help!
          

          try to access to your admin page only
          see if you get the same error if so
          Comment out "Hosts" and "Addresses" lines in the admin-serv/config/ns-admin.conf
          or change the value to *
          Jong
          "Rainer Muelders" <[email protected]> wrote:
          >
          >Hello All!
          >
          >When I send the attached servlet directly to WLS 5.1 as Web-server it works fine.
          >But when I use NES 3.5.1 as a Web-Server I receive the message:
          >
          >"Your client is not allowed to access the requested object."
          >
          >How can I solve this problem?
          >
          >Thanks for any help!
          

Similar Messages

  • How to compile and run a Java servlet using the BEA weblogic server

              Hi,
              Could you help me out as to how to compile a servlet using Web Logic server.I have written a Servlet program and have also set up the environment in the "c:\bea\wlserver6.0\config\examples" folder by giving the command setExamplesEnv.cmd.
              I have stored my GreetingServlet.java file in "c:\bea\wlserver6.0\samples\examples\servlets" folder.
              How do I compile my servlet now?
              Vid
              

    Hello,
    1. The .form file was used by Netbean's GUI builder to create the .java and is not needed for compilation.
    2..../src # javac -classpath "..." mytool/*.java
    I guess the package mytool was not coped with.
    Alternatively it is worth to use the ant build tool also used by Netbeans.
    Then you can make a jar from the class files, indicate in the manifest.mf file:
    1. the main class
    2. the library jars

  • How to run jsp and servlet using JBOSS server

    Dear Friend,
    I have JBoss application server and Eclipse id
    now i want to run JSP and Servlet but i am not getting the place where to place my servlet class file to run it .
    before that i run jsp and servlet using tomcat5.0 but in that i place my servlet class in WEB-INF/classes folder and do corresponding entry in web.xml file and run it through browser.
    now i want to use JBOSS how it is possible
    PLZ Help me

    Is the servlet class defined in a package.? If servlet class package is servlets., copy the servlet to
    WEB-INF/classes/servlets directory.

  • Accessing servlets using login and goto

    Hi,
    I'm having a problem in accessing servlets without visiting the DesktopServlet. There is no problem if the servlet does not require a parameter, but if I try to pass a parameter to the servlet, it does not pass the parameter -
    Without visiting the DesktopServlet when I try to visit an servlet X , it gives me a session exception.
    Thrown SessionException : Invalid service host name.
    I use the following code to login and go to the servlet :
    String redirectTarget = "login?&goto=" + req.getRequestURI() + "&hotelComponent=" + hotelComponent;
    resp.sendRedirect(redirectTarget);
    Inside the doGet of the servlet, I now try to read the hotelComponent parameter -
    String hotelComponent = req.getParameter("hotelComponent");
    But now I get a null. I can not get the hotelComponent parameter. Any suggestions will be very helpful
    Thanks in advance
    Partha

    Thanks for the suggestions ! The original problem of not being able to pass parameters like -
    "login?&goto=" + req.getRequestURI + "?param=" + value"
    has been solved by encoding the URL string sent to resp.sendRedirect.
    However the suggestion you have given regarding setting of cookies in the browser might have a bearing on my actual problem. I'm trying to do away with the redirection to the login servlet in the DesktopServlet.
    Here is what I'm trying to do to make our website searchengine friendly - using WGET scrape the DesktopServlet and set it as the index.html. When somebody tries to access the links which are ordinary servlets, it gives a session exception. I catch the session exception and in the catch block use "login?&goto" to do a response.sendRedirect. This does a login and gets me the session.
    All the servlets work fine except for one which is identical to the ones working except for the fact it is a post from a form on the DesktopServlet. Here I get a HTTP 400 Bad Request error. I've noticed that when I clear the cache and try I get a better response.
    Any suggestion on how to overcome this ( possibly by setting cookies ) would be greatly appreciated.
    Thanks in advance

  • Load Balancing and WLS primary server offset

    I've got a load balancer in front of my WLS cluster, and I'm trying to
              set up load balancing based on WLS clustering. What I need to know to
              do this is the offset within the cookie that's responsible for
              determining which machine within the cluster to direct to.
              Any idea how I can get this information?
              thanks,
              cfraser
              

    Chris Fraser wrote:
              > The proxy/plug-in solution sounds pretty cool, but I've got a high speed
              > Alteon Load Balancer already set up. I would prefer to use that as the load
              > balancer to the WL cluster rather than pay to bring another WLS online to do
              > pretty much what the load balancer, that I already own, can do. I know that
              > going this route means that we're probably not going to be able to do things
              > like failover to the secondary when the primary dies, but we will be able to
              > load balance and also have the ability to dynamically add/delete servers
              > from the list of available servers as they are brought up/down.
              In Memory session replication doesn't work without our plugins. I will have to
              do little bit of investigation to figure out if other persistence mechanism's
              would work without our plugins if you are interested in them. I have to remind
              you though that other types of persistence mechanism's we support are slower
              compared to in memory session replication.
              > Are there any plans to work with an Alteon or a Foundry to have their Load
              > Balancers act as the front end to a WLS cluster?
              Currently none. We are taking steps to make the plugin's and cluster more
              robust, we currently don't have any plans to work with other 3rd party vendors.
              > For us it would be ideal, because we wouldn't have to support another piece of
              > software, we would just
              > have to support the hardware based Alteon, which can handle thousands of
              > transactions per second.
              > I understand that the primary and secondary server information is available
              > in the sessionID, I'm just not quite sure how to extract it.
              This information is saved in the cookie. But I wouldn't count that, as we
              have plans to change this. I cannot give your more details.
              > Is there a particular offset within the session ID where it can always be
              > found?
              I don't quite get what you mean here.
              Hope this helps.
              - Prasad
              > thanks for the help,
              > cfraser
              > ----------
              > C h r i s t o p h e r A . F r a s e r
              > Director, Technology
              > macroplay.com, Inc.
              > [email protected]
              >
              > Viresh Garg wrote:
              >
              > > You should be using
              > > -- NES +NSAPI Plugin
              > > -- IIS + ISAPI Plugin
              > > -- WEblogic server acting as proxy
              > > -- Apache +Apache Plugin ( only in Denali)
              > >
              > > front-ending your Weblogic cluster
              > >
              > > These proxies/plug-ins are smart to do a lot of things like:
              > >
              > > -- Load balancing in weblogic cluster
              > > -- Adding/deleting servers dynamically in cluster when the servers
              > > join/leave Weblogic cluster
              > > -- failover to secondary when primary dies.
              > >
              > > As far as the information about primary and secondary is concerned it is
              > > available in session ID.
              > >
              > > --Viresh Garg
              > >
              > > Chris Fraser wrote:
              > >
              > > > I've got a load balancer in front of my WLS cluster, and I'm trying to
              > > > set up load balancing based on WLS clustering. What I need to know to
              > > > do this is the offset within the cookie that's responsible for
              > > > determining which machine within the cluster to direct to.
              > > >
              > > > Any idea how I can get this information?
              > > >
              > > > thanks,
              > > > cfraser
              

  • Configuration with Tomcat, Firewall and WLS 5.1

    Hi all,
              I have been reading the cluster documentation for WLS 5.1, but I can't
              find any information about a cofiguration which looks like (Top of list
              is the 'front'):
              Router
              (Some kind of load balancer)
              Cluster of Apache and Tomcat servers
              Firewall
              Cluster of WLS 5.1 servers
              Database
              To me it looks like all the configurations in the documentation use WLS
              to handle dynamic content (Servlets/Jsp).
              We will use Tomcat as Servlet/Jsp runner, and or not interested in using
              WLS for such things...
              WLS will be used as an EJB container, and we aren't using any statefull
              beans.
              So I have a few questions regarding the configuration above:
              1. Do we need to run the proxy plug-in in the web layer?
              2. Can we have a firewall between the web layer and the WLS cluster?
              3. How should the JSP pages choose a WLS server? Should we write some
              kind of proxy plug-in for Tomcat?
              Best regards
              /Kaj
              ~~~~~~~~~ ~~~~ ~~~ ~~ ~ ~ ~ ~
              [email protected]
              +46 70 4200148
              

    Router          > (Some kind of load balancer)
              > Cluster of Apache and Tomcat servers
              > Firewall
              > Cluster of WLS 5.1 servers
              > Database
              I've seen:
              Router
              Firewall
              (Some kind of load balancer)
              Group of Apache proxies
              Cluster of WLS 5.1 servers
              Database
              > To me it looks like all the configurations in the documentation use WLS
              > to handle dynamic content (Servlets/Jsp).
              > We will use Tomcat as Servlet/Jsp runner, and or not interested in using
              > WLS for such things...
              > WLS will be used as an EJB container, and we aren't using any statefull
              > beans.
              That's possible. I'd suggest anything but Tomcat though ... it's slow as
              mud. Check out Caucho Resin.
              > 1. Do we need to run the proxy plug-in in the web layer?
              No. The proxy is for proxying Http requests. Instead you will be looking
              up EJBs and getting cluster-aware stubs from Weblogic.
              > 2. Can we have a firewall between the web layer and the WLS cluster?
              Yes. But that means that there will be some way for systems other than your
              JSP/Servlet servers from accessing your EJBs. (Remember, if your
              JSP/Servlet servers have a way to poke through the firewall, then
              theoretically so does everyone else.)
              Instead, consider a simple port forwarding system. Close everything but 80
              and 443 and forward those to your load balancers and then on to your
              Apaches. To have redundancy on your firewalls, reverse the order of load
              balancer and firewall.
              > 3. How should the JSP pages choose a WLS server? Should we write some
              > kind of proxy plug-in for Tomcat?
              I believe that is the job of the cluster-aware EJB home stub.
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              +1.617.623.5782
              WebLogic Consulting Available
              "Kaj Bjurman" <[email protected]> wrote in message
              news:[email protected]...
              > Hi all,
              >
              

  • Unable to deploy a simple servlet using WAR file on Oracle9iAS v9.0.3

    Hi All,
    I am facing problem while deploying a simple servlet using WAR file on Oracle 9i App Server.
    I have installed Oracle9iAS J2EE and Web Cache v9.0.3 on Windows 2000 server.
    It includes:
         - Oracle HTTP Server
         - Oracle9iAS Containers for J2EE
         - Oracle9iAS Web Cache
         - Oracle Enterprise Manager
    The release of installed Oracle9iAS is Release 2 (9.0.3)      
    I referred following link to Deploy Applications Using WAR file:
         http://otn.oracle.com/products/ias/daily/sept12.html
    As mentioned in this documentation I have followed following steps to deploy WAR file:
    1] I have created a war file by name SimpleServlet.war. In SimpleServlet.war, there is a servlet by name Simple which prints time at which servlet was accessed.
    2] I have modified <ora9ias_home>\j2ee\home\config\application.xml and added following web module entry:
         <web-module id="SimpleServlet" path="../../home/applications/SimpleServlet.war" />
    3] To make this module accessible from over the web, I have modified file
         <ora9ias_home>\j2ee\home\config\default-web-site.xml and added following entry:
         <web-app application="SimpleServlet" name="SimpleServlet" root="/SimpleServlet"/>
    4] I saved both the files and started Oracle HTTP Server and accessed page as below:
              http://<server>:7777/SimpleServlet/Simple
    where Simple is servlet in SimpleServlet.war file.          
    In the browser, The page cannot be found is shown to user. I have verified that SimpleServlet.war is extracted to SimpleServlet folder under <ora9ias_home>\j2ee\home\applications folder. I found that Simple.class is stored under WEB-INF/classes folder and web.xml contains correct entry for url pattern for servlet Simple.
    What else could be the problem? Am I placing the war file in wrong place or modifying application.xml or default-web-site.xml in a wrong directory?
    This is very urgent. Please help me with your valuable comments on this.
    Thanks in advance.
    Regards,
    Sandesh

    Hi All,
    I am facing problem while deploying a simple servlet
    using WAR file on Oracle 9i App Server.
    I have installed Oracle9iAS J2EE and Web Cache v9.0.3
    on Windows 2000 server.
    It includes:
         - Oracle HTTP Server
         - Oracle9iAS Containers for J2EE
         - Oracle9iAS Web Cache
         - Oracle Enterprise Manager
    The release of installed Oracle9iAS is Release 2
    (9.0.3)      
    I referred following link to Deploy Applications
    Using WAR file:
         http://otn.oracle.com/products/ias/daily/sept12.html
    As mentioned in this documentation I have followed
    following steps to deploy WAR file:
    1] I have created a war file by name
    SimpleServlet.war. In SimpleServlet.war, there is a
    servlet by name Simple which prints time at which
    servlet was accessed.
    2] I have modified
    <ora9ias_home>\j2ee\home\config\application.xml and
    added following web module entry:
    <web-module id="SimpleServlet"
    path="../../home/applications/SimpleServlet.war" />
    3] To make this module accessible from over the web,
    I have modified file
    <ora9ias_home>\j2ee\home\config\default-web-site.xml
    and added following entry:
    <web-app application="SimpleServlet"
    name="SimpleServlet" root="/SimpleServlet"/>
    4] I saved both the files and started Oracle HTTP
    Server and accessed page as below:
              http://<server>:7777/SimpleServlet/Simple
    where Simple is servlet in SimpleServlet.war file.          
    In the browser, The page cannot be found is shown to
    user. I have verified that SimpleServlet.war is
    extracted to SimpleServlet folder under
    <ora9ias_home>\j2ee\home\applications folder. I found
    that Simple.class is stored under WEB-INF/classes
    folder and web.xml contains correct entry for url
    pattern for servlet Simple.
    What else could be the problem? Am I placing the war
    file in wrong place or modifying application.xml or
    default-web-site.xml in a wrong directory?
    This is very urgent. Please help me with your
    valuable comments on this.
    Thanks in advance.
    Regards,
    SandeshHave you restarted you http server and then tried to load it again? Are you using the right port; maybe you have to use port 7778? Check you server settings in the http server instance. Also check your url binding of you application at Farm > Application Server: infrastructurehost > OC4J_instance > Application: appname > Web Module: modulename
    Good luck!
    rgds Thomas

  • Unable to deploy a simple servlet using WAR file

    Hi All,
    I am facing problem while deploying a simple servlet using WAR file on Oracle 9i App Server.
    I have installed Oracle 9i App Server. I referred following link to Deploy Applications Using WAR file:
         http://otn.oracle.com/products/ias/daily/sept12.html
    As mentioned in this documentation I have followed following steps to deploy WAR file:
    1] I have created a war file by name SimpleServlet.war. In SimpleServlet.war, there is a servlet by name Simple which prints time at which servlet was accessed.
    2] I have modified <ora9ias_home>\j2ee\home\config\application.xml and added following web module entry:
         <web-module id="SimpleServlet" path="../../home/applications/SimpleServlet.war" />
    3] To make this module accessible from over the web, I have modified file
         <ora9ias_home>\j2ee\home\config\default-web-site.xml and added following entry:
         <web-app application="SimpleServlet" name="SimpleServlet" root="/SimpleServlet"/>
    4] I saved both the files and started Oracle HTTP Server and accessed page as below:
              http://<server>:7777/SimpleServlet/Simple
    where Simple is servlet in SimpleServlet.war file.          
    In the browser, The page cannot be found is shown to user. I have verified that SimpleServlet.war is extracted to SimpleServlet folder under <ora9ias_home>\j2ee\home\applications folder. I found that Simple.class is stored under WEB-INF/classes folder and web.xml contains correct entry for url pattern for servlet Simple.
    What else could be the problem? Am I placing the war file in wrong place or modfiying application.xml or default-web-site.xml in a wrong directory?
    This is very urgent. Please help me with your valuable comments on this.
    Thanks in advance.
    Regards,
    Sandesh

    Hi Juliana,
    Thanks a lot for your suggestion.
    I am sorry if I have posted this message to a wrong forum. This is first time I am posting a message to OTN. I will resend message to J2EE forum as per you suggestion.
    Meanwhile, please note information you asked for is as below:
    I installed Oracle9iAS J2EE and Web Cache v9.0.3 on Windows 2000 server.
    It includes:
         - Oracle HTTP Server
         - Oracle9iAS Containers for J2EE
         - Oracle9iAS Web Cache
         - Oracle Enterprise Manager
    The release of installed Oracle9iAS is Release 2 (9.0.3)      
    Please do reply at the earliest.
    Once again thanks and look forward to hear from you.
    Regards,
    Sandesh

  • Servlets/JDBC - Connect to database ONCE and not in every servlet - How?

    Hello, I'm using servlets and JDBC.
    In every servlet , i connect to the database and then i close the connection, but this is not ptactical.
    I would like to connect to the database once (at the beginning) when container starts and then close the connection.
    How am i supposed to do that?
    Thanks, in advance!

    Bad idea. Don't do that. The connection will timeout sooner or later (depends on DB used, it's usually around 30 mins) and your application will crash.
    You should always acquire and close the connection (and statement and resultset!) in the shortest possible scope. To improve connecting performance just use connection pooling.
    Create a DAO class which does all the task and just instantiate and assign it as Servlet class variable during Servlet's init() method. For more insights and code samples start here: [http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html].
    To go back to your fundamental question, doing some stuff during startup and shutdown of webapp, you could use the ServletContextListener for this. But again, do NOT do this to get hold of an external resource such as a connection! It's receipt for trouble.

  • Problem to connect to mysql from servlet using a javabean

    Hi,
    I'm new here and beginner on java to.
    I have problem to connect to MySql database, by a connection javabean.
    It's the following: a HTML page calls a servlet and this servlet imports the package connection javabean.
    It has no problem when I establish the connection inside the servlet, with all its methods (public and private). But i want to separate the code connection from servlet.
    Detail: there is no problem, using the javabean to connect to MS Access database.
    I put "mysql-connector-java-3.1.12-bin.jar" file inside WEB-INF/lib application and common/lib directories.
    I set the classpath:
    SET CLASSPATH=%CATALINA_HOME%\COMMON\LIB\mysql-connector-java-3.1.12-bin.jar;%CLASSPATH%
    I think that the servlet cannot create an instance of javabean, because passed by catch exception of the servlet init method.
    But I don't know why.
    Please Why?
    Below there are the fragment of errors, servlet code e javabean code.
    Thank you.
    Zovao.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    at CadServletFileBeanConexArq.doPost(CadServletFileBeanConexArq.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    Note: The line 47 is calling insertIntoDB javabean method.
    ========///////////////===============
    // Here is the servlet CadServletFileBeanConexArq.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import conJdbc.*;
    public class CadServletFileBeanConexArq extends HttpServlet {
    public ConexPed connect = null;
    private String driver = "com.mysql.jdbc.Driver";
    private String URL = "jdbc:mysql://localhost:3306/cadastro";
    public void init( ServletConfig config )
    throws ServletException
    super.init( config );
    try
    connect = new ConexPed(driver, URL, "monty", "some_pass");
    catch ( Exception e )
    e.printStackTrace();
    connect = null;
    public void doPost( HttpServletRequest req,
    HttpServletResponse res )
    throws ServletException
    boolean success = true;
    String email, nome, sobrenome, produto, valor;
    email = req.getParameter( "Email" );
    nome = req.getParameter( "Nome" );
    sobrenome = req.getParameter( "Sobrenome" );
    produto = req.getParameter( "Produto" );
    valor = req.getParameter( "Valor" );
    res.setContentType( "text/html" );
    if ( email.length() > 0 && nome.length() > 0 && sobrenome.length() > 0 && valor.length() > 0 )
    /* inserting data */
    success = connect.insertIntoDB(
    "'" + email + "','" + nome + "','" + sobrenome + "','" + produto + "'", Double.parseDouble(valor) );
    //closing connection
    public void destroy()
    connect.fecharConexao();
    =============///////////////============
    Here is the JavaBean.
    package conJdbc;
    import java.sql.*;
    public class ConexPed
    public Connection connection;
    public Statement statement;
    public ConexPed (String driver, String urlServidor, String user, String password)
    try
    Class.forName(driver);
    connection = DriverManager.getConnection(urlServidor,user,password);
    catch (ClassNotFoundException ex)
    System.out.println("N�o foi poss�vel encontrar a classe do Driver: " + driver);
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel conectar ao servidor");
    try
    statement = connection.createStatement();
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel criar a statement");
    *Inserting data to database
    public synchronized boolean insertIntoDB( String stringtoinsert, double valor)
    try
    statement.executeUpdate( "INSERT INTO pedido values (" + stringtoinsert + " , " + valor + ");" );
    catch ( Exception e ) {
    System.err.println(
    "ERROR: Problemas ao adicionar nova entrada" );
    e.printStackTrace();
    return false;
    return true;
    * Close statement.
    public void fecharStatement()
    try
    statement.close();
    catch (SQLException ex)
    ex.printStackTrace();
    * close database
    public void fecharConexao()
    try
    connection.close();
    catch (SQLException ex)
    ex.printStackTrace();
    }

    Hi,
    I'm new here and beginner on java to.
    I have problem to connect to MySql database, by a connection javabean.
    It's the following: a HTML page calls a servlet and this servlet imports the package connection javabean.
    It has no problem when I establish the connection inside the servlet, with all its methods (public and private). But i want to separate the code connection from servlet.
    Detail: there is no problem, using the javabean to connect to MS Access database.
    I put "mysql-connector-java-3.1.12-bin.jar" file inside WEB-INF/lib application and common/lib directories.
    I set the classpath:
    SET CLASSPATH=%CATALINA_HOME%\COMMON\LIB\mysql-connector-java-3.1.12-bin.jar;%CLASSPATH%
    I think that the servlet cannot create an instance of javabean, because passed by catch exception of the servlet init method.
    But I don't know why.
    Please Why?
    Below there are the fragment of errors, servlet code e javabean code.
    Thank you.
    Zovao.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    at CadServletFileBeanConexArq.doPost(CadServletFileBeanConexArq.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    Note: The line 47 is calling insertIntoDB javabean method.
    ========///////////////===============
    // Here is the servlet CadServletFileBeanConexArq.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import conJdbc.*;
    public class CadServletFileBeanConexArq extends HttpServlet {
    public ConexPed connect = null;
    private String driver = "com.mysql.jdbc.Driver";
    private String URL = "jdbc:mysql://localhost:3306/cadastro";
    public void init( ServletConfig config )
    throws ServletException
    super.init( config );
    try
    connect = new ConexPed(driver, URL, "monty", "some_pass");
    catch ( Exception e )
    e.printStackTrace();
    connect = null;
    public void doPost( HttpServletRequest req,
    HttpServletResponse res )
    throws ServletException
    boolean success = true;
    String email, nome, sobrenome, produto, valor;
    email = req.getParameter( "Email" );
    nome = req.getParameter( "Nome" );
    sobrenome = req.getParameter( "Sobrenome" );
    produto = req.getParameter( "Produto" );
    valor = req.getParameter( "Valor" );
    res.setContentType( "text/html" );
    if ( email.length() > 0 && nome.length() > 0 && sobrenome.length() > 0 && valor.length() > 0 )
    /* inserting data */
    success = connect.insertIntoDB(
    "'" + email + "','" + nome + "','" + sobrenome + "','" + produto + "'", Double.parseDouble(valor) );
    //closing connection
    public void destroy()
    connect.fecharConexao();
    =============///////////////============
    Here is the JavaBean.
    package conJdbc;
    import java.sql.*;
    public class ConexPed
    public Connection connection;
    public Statement statement;
    public ConexPed (String driver, String urlServidor, String user, String password)
    try
    Class.forName(driver);
    connection = DriverManager.getConnection(urlServidor,user,password);
    catch (ClassNotFoundException ex)
    System.out.println("N�o foi poss�vel encontrar a classe do Driver: " + driver);
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel conectar ao servidor");
    try
    statement = connection.createStatement();
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel criar a statement");
    *Inserting data to database
    public synchronized boolean insertIntoDB( String stringtoinsert, double valor)
    try
    statement.executeUpdate( "INSERT INTO pedido values (" + stringtoinsert + " , " + valor + ");" );
    catch ( Exception e ) {
    System.err.println(
    "ERROR: Problemas ao adicionar nova entrada" );
    e.printStackTrace();
    return false;
    return true;
    * Close statement.
    public void fecharStatement()
    try
    statement.close();
    catch (SQLException ex)
    ex.printStackTrace();
    * close database
    public void fecharConexao()
    try
    connection.close();
    catch (SQLException ex)
    ex.printStackTrace();
    }

  • How to test servlet using Junit test????

    Hello everybody
    Does anybody know how to test an servlet class using Junit without using Cactus test . Is it possible to test a servlet using Junit without cactus test.Plz tell me the process how to test a servlet using Junit test .
    Regards
    srikant

    1) Do yoiu mean how to "run" your servlet code with sample parameter? This call manual testing with a sample run of you code. You need a web server(eg Tomcat), create a webapp with your servlet then deploy it there in order to run it.
    2) httpunit and junit are framework to write test case code that can be automated and repeatable. Plz read their doc.
    3) Your sample code me a very wrong way to retrieve and convert servlet parameters.
    Get a java toturial and servlet tutorial book and read it over the weekend. You need to get at least the basic.

  • Connecting a servlet using a midlet

    Hi,
    I am trying to connect to a servlet using a Midlet. The servlet is running fine on Apache Tomcat and I m able to build the MIDlet using J2MEWTK . But when I execute the Midlet on an emulator it shows me some code of html page of which the important line which might give u some hint is :
    the requested resource (/hitservlet) is not available.
    I wrote the code of HitServlet and Hitmidlet using a pdf on net....Do I need to install something else for executing this? I dont understand where is the problem. Should I post the codes? Is it something related to aliases...as indicated by some some tutorial...if so plss elaborate on it..
    If anybdy has any idea ...plss help me get out of this problem...
    Thanx
    Smeeta

    Have you added the URL of the Servlet into the J2ME application?
    Settings -> UserDefined Tab
    Thinks its
    HitMIDlet.URL and its value should be the URL of the Servlet

  • When to use doGet(...) and when to use doPost(..)

    Hi,
    here is what i would like to do:
    I have a html file that will take user input and pass these inputs to a servlet as parameters. the servlet then uses these input parameters to query for data in a database and then write this results back to the browser. Here is my problem:
    If I use doGet(...) and hardcode the input parameters instead of taking them from the html file, I then can compile and run it from Jdev IDE. And if I use doPost(..) instead, I can only compile the servlet, but when run, I got the error message :
    "The page cannot be displayed
    The page you are looking for cannot be displayed because the address is incorrect."
    To my understanding, please correct me if I am wrong,we use doPost() to accept pararmeters from a html. Please help me. thank you very much.
    Tran T.
    codes are as below:
    <HTML>
    <HEAD><TITLE>Session Payment Status</TITLE></HEAD>
    <BODY>
    <FORM ACTION="http://localhost:8080/servlet/SessionPaymentStatus" TARGET="FRA2" METHOD="POST">
    <CENTER><H1><FONT COLOR="GREEN" SIZE="5"> Session Payment Status</FONT></H1></CENTER>
    </HTML>
    And my servlet is:
    package paymentstatus;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import gmstocms.*;
    import java.util.*;
    import com.gaexpress.javaadapter.*;
    public class PaymentStatus extends HttpServlet {
    //CMS Related
    private String xmlRecord = null;
    private String storedProc = null;
    private String ID = null;
    private CmsXmlParser parsedRecord = null;
    private Vector vecData = null;
    //Record Header
    String RecordID = null;
    public void init(){
    this.storedProc = "OLEDB$GETSESS";
    this.ID = "CE97607";
    public String getCMSRecord(){
    //xmlRecord = new String (CMSTest.executeSP("OLEDB$GETSESS","CE97465"));
    return new String (CMSTest.executeSP(storedProc,ID));
    public CmsXmlParser getParsedRecord(){
    if(parsedRecord == null){
    parsedRecord = new CmsXmlParser(getCMSRecord());
    return parsedRecord;
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
    res.setContentType("text/html");
    //res.setHeader("Welcome to Directional Project", null);
    PrintWriter out = res.getWriter();
    getParameters(req);
    out.println("<LEFT><H2><FONT COLOR=GREEN SIZE=3>" + getParsedRecord().getCMSRecordHeader() + "</FONT></H2></LEFT>");
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE> Bidirectional Project </TITLE>");
    out.println("</HEAD>");
    out.println("<LEFT><H2><FONT COLOR=GREEN SIZE=3>" + getParsedRecord().getCMSRecordHeader() + "</FONT></H2></LEFT>");
    out.println("</HTML>");
    out.close();
    //get the parameters to for the email to be sent to the given address
    private void getParameters(HttpServletRequest req) throws ServletException, IOException {
    this.storedProc = req.getParameter("optProName");
    this.ID = req.getParameter("optCustID");
    null

    U can use doPost() simply call the doGet() in the doPost() as follow...
    Let me know if u still have problem...
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
    doGet(req, res);
    null

  • Problem running servlet using PJA tools

    Hi
    I am trying to run the TeksSurveyPie servlet from the PJA Package.But everytime i run it says
    Internal error: Unexpected error condition thrown (java.lang.NoClassDefFoundError: TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie),TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie)), stack: java.lang.NoClassDefFoundError: TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:495)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:110)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$1(URLClassLoader.java:217)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:192)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:300)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:290)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:256)
    at java.lang.ClassLoader.findSystemClass(ClassLoader.java:629)
    at com.iplanet.server.http.servlet.NSServletLoader.findClass(NSServletLoader.java:152)
    at com.iplanet.server.http.servlet.NSServletLoader.loadClass(NSServletLoader.java:108)
    at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:337)
    at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173)
    at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:427)
    I am tryin to access the servlet like this
    https://avenger/servlet/TeksSurveyPie?survey=Yes
    Pls tell me where i am going wrong...????Its preety urgent ....
    thanks
    prabhu

    the servlet is as below for reference .....
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletException;
    import javax.servlet.ServletConfig;
    import javax.servlet.UnavailableException;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.OutputStream;
    import java.util.Properties;
    import java.util.Vector;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import java.util.StringTokenizer;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.Frame;
    import java.awt.AWTError;
    import java.awt.Image;
    import java.awt.image.FilteredImageSource;
    import Acme.JPM.Encoders.GifEncoder;
    import com.eteks.filter.Web216ColorsFilter;
    import com.eteks.awt.servlet.PJAServlet;
    * This servlet manages in a simple way a dynamic survey and returns the pie of the survey.
    * It can be called in either ways :
    * <UL><LI><code>.../servlet/com.eteks.servlet.TeksSurveyPie?survey=mySurvey&answer=myAnswer</code>
    * adds the answer <code>myAnswer</code> to the survey <code>mySurvey</code>,
    * and then returns the pie of the current state of <code>mySurvey</code>.
    * <LI><code>.../servlet/com.eteks.servlet.TeksSurveyPie?survey=mySurvey</code>
    * simply returns the pie of the current state of <code>mySurvey</code>.</UL>
    * <P>To be platform independant, the servlet uses <code>com.eteks.awt.servlet.PJAServlet</code> as super class,
    * to have at disposal an image into which graphics operation can be performed.<BR>
    * <code>com.eteks.awt.PJAServlet</code> class and depending classes of <code>com.eteks.awt</code> packages
    * must be in the servlet engine classpath, and at least one .pjaf font file (Pure Java AWT Font) must exist
    * in the user directory or in the directory set in the <code>java.awt.fonts</code> system property,
    * if JVM version <= 1.1.<BR>
    public class TeksSurveyPie extends PJAServlet
    Properties surveysParam = new Properties ();
    String fontsDir = ""; // Default value for "java.awt.fonts" .pjaf fonts directory initParameter
    String surveysFile = fontsDir + File.separator + "survey.txt"; // Default value for survey file initParameter
    // Colors used to fill the pie
    final Color colors [] = {Color.blue,
    Color.green,
    Color.red,
    Color.cyan,
    Color.magenta,
    Color.gray,
    Color.yellow,
    Color.pink,
    Color.orange,
    Color.white};
    final Color penColor = Color.black;
    public void initPJA (ServletConfig config) throws ServletException
    // Store the ServletConfig object and log the initialization
    super.initPJA (config);
    // Retrieves surveys file path
    String param = getInitParameter ("surveysFile");
    if (param != null)
    surveysFile = param;
    param = getInitParameter ("fontsDir");
    if (param != null)
    fontsDir = param;
    FileInputStream in = null;
    try
    in = new FileInputStream (surveysFile);
    surveysParam.load (in);
    catch (IOException e)
    { } // Empty properties
    finally
    try
    if (in != null)
    in.close ();
    catch (IOException ex)
    public void destroyPJA ()
    try
    surveysParam.save (new FileOutputStream (surveysFile), "Survey file");
    catch (IOException e)
    { } // Properties can't be saved
    public String getFontsPath ()
    return super.getFontsPath () + File.pathSeparator
    + fontsDir;
    public void doPostPJA (HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
    doGetPJA (request, response);
    public void doGetPJA (HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
    String survey = request.getParameter ("survey"); // Survey name
    String answer = request.getParameter ("answer"); // Proposed answer
    String paramWidth = request.getParameter ("width");
    String paramHeight = request.getParameter ("height");
    int width = paramWidth == null ? 200 : Integer.parseInt (paramWidth);
    int height = paramHeight == null ? 100 : Integer.parseInt (paramHeight);
    // v1.1 : Changed code to enable image creation
    // even if PJAToolkit couldn't be loaded by Toolkit.getDefaultToolkit ()
    Image image = createImage (width, height);
    if (survey == null)
    survey = "";
    if (answer != null)
    String key = survey + "_" + answer;
    String value = surveysParam.getProperty (key);
    if (value != null)
    // If the answer already exists, increase its value
    surveysParam.put (key, String.valueOf (Integer.parseInt (value) + 1));
    else
    String surveyAnswers = surveysParam.getProperty (survey);
    // Add this answer to the other ones
    if (surveyAnswers == null)
    surveysParam.put (survey, answer);
    else
    surveysParam.put (survey, surveyAnswers + "," + answer);
    surveysParam.put (key, "1");
    Hashtable answers = new Hashtable ();
    Vector sortedAnswers = new Vector ();
    synchronized (surveysParam)
    String surveyAnswers = surveysParam.getProperty (survey);
    if (surveyAnswers != null)
    for (StringTokenizer tokens = new StringTokenizer (surveyAnswers, ",");
    tokens.hasMoreTokens (); )
    String token = tokens.nextToken ();
    int answerCount = Integer.parseInt (surveysParam.getProperty (survey + "_" + token));
    answers.put (token, new Integer (answerCount));
    // Seek the good place to insert this element
    int i;
    for (i = 0; i < sortedAnswers.size (); i++)
    if (answerCount > ((Integer)answers.get (sortedAnswers.elementAt (i))).intValue ())
    break;
    sortedAnswers.insertElementAt (token, i);
    // Compute the pies of the survey
    drawSurveyPies (image, answers, sortedAnswers, width, height);
    // Send generated image
    sendGIFImage (image, response);
    * Generates a GIF image on the response stream from image.
    public void sendGIFImage (Image image, HttpServletResponse response) throws ServletException, IOException
    // Set content type and other response header fields first
    response.setContentType("image/gif");
    // Then write the data of the response
    OutputStream out = response.getOutputStream ();
    try
    new GifEncoder (image, out).encode ();
    catch (IOException e)
    // GifEncoder may throw an IOException because "too many colors for a GIF" (> 256)
    // were found in the image
    // Reduce the number of colors in that case with Web216ColorsFilter basic filter
    new GifEncoder (new FilteredImageSource (image.getSource (),
    new Web216ColorsFilter ()),
    out).encode ();
    out.flush ();
    private void drawSurveyPies (Image image,
    Hashtable answers,
    Vector sortedAnswers,
    int width,
    int height)
    Graphics gc = image.getGraphics ();
    // Draw a shadow
    gc.setColor (penColor);
    gc.fillOval (1, 1, height - 3, height - 3);
    gc.fillOval (2, 2, height - 3, height - 3);
    // Compute the sum of all values
    int sum = 0;
    for (Enumeration e = answers.elements ();
    e.hasMoreElements (); )
    sum += ((Integer)e.nextElement ()).intValue ();
    for (int accum = 0, i = 0, deltaY = 0; i < sortedAnswers.size (); i++, deltaY += 15)
    int answerValue = ((Integer)answers.get (sortedAnswers.elementAt (i))).intValue ();
    int startAngle = accum * 360 / sum;
    int angle = answerValue * 360 / sum;
    // Fill the anwser pie
    gc.setColor (colors [i % colors.length]);
    gc.fillArc (0, 0, height - 3, height - 3, startAngle, angle);
    // Draw a separating line
    gc.setColor (penColor);
    gc.drawLine ((height - 3) / 2, (height - 3) / 2,
    (int)((height - 3) / 2. * (1 + Math.cos (startAngle / 180. * Math.PI)) + 0.5),
    (int)((height - 3) / 2. * (1 - Math.sin (startAngle / 180. * Math.PI)) + 0.5));
    accum += answerValue;
    if (deltaY + 15 < height)
    // Add a comment
    gc.setColor (colors [i % colors.length]);
    gc.fillRect (height + 6, deltaY + 1, 13, 10);
    gc.setColor (penColor);
    gc.drawRect (height + 5, deltaY, 14, 11);
    // Draw is done with default font
    gc.drawString (String.valueOf (100 * answerValue / sum) + "% " + (String)sortedAnswers.elementAt (i),
    height + 22, deltaY + 9);
    gc.drawLine ((height - 3) / 2, (height - 3) / 2, height - 3, (height - 3) / 2);
    // Draw a surrounding oval
    gc.drawOval (0, 0, height - 3, height - 3);
    Thx
    prabhu

  • Obtaining client certificate in servlet using apache + tomcat

    Hi,
    I'm porting a webapplication from Javawebserver to Apache/1.3.6 (Win32) mod_jk mod_ssl/2.2.6 OpenSSL/0.9.2b
    The application needs to get the client certificate hash code.
    Using Javawebserver I used
    request.getAttribute ("javax.net.ssl.cipher_suite");
    request.getAttribute("javax.net.ssl.peer_certificates");
    etc
    How do I set up the apache webserver so that I can read the client certificate and what is the attribute called?
    I've tried this in the httpd.conf:
    SSLOptions +ExportCertData
    And the attribute:
    "SSL_CLIENT_CERT"
    Like it says in the Tomcat documentation.
    I'm not sure if I need to set up Tomcat as well..
    Any help would be greatly appriciated!
    Sincerely,
    AM Hjemaas

    Yup use ajp13 not ajp12 or mod_webapp
    refer to http://www.galatea.com/flashguides/apache-tomcat-24-win32.xml on setting up..
    THIS IS IMPORTANT!!!
    use Apache mod_jk.dll diretive:
    JkEnvVar Apache_Env_Var FORWARD_ALIAS
    this will send a apache environment variable (http://myapache/cgi-bin/printenv.pl to see whats available) to Tomcat
    JkEnvVar SSL_CLIENT_CERT SSL_CLIENT_CERT
    Then in Tomcat servlet use request.getAttribute("SSL_CLIENT_CERT") to get the cert in PEM format
    Hope this helps
    Jay

Maybe you are looking for

  • Can not load adobe flash and now none of my video will work. may go back to internet ex.

    can not load adobe flash player. tried plug in- and adobe site. nothing works and now I can not view any of my video. OH ye, you are not listed under any of the plug ins. are you windows? Mac? 64? what?

  • RAZR MAXX drops calls "on command" and randomly

    I have a RAZR MAXX (two months old). If I use my Plantronics Pro HD Bluetooth device, the phone will suddenly drops a phone call without any reason. If I don't use the BT device and use only the phone/speaker, everything is working fine. The same goe

  • Preview App quits unexpectedly OSX 10.10.2

    Hi to all, I have a problem with Preview app in OSX 10.10.2. It crashes any time when trying to open any file, no matter the type (PDF, PNG, etc). I have OSX 10.10.2 stock. Just with a few apps installed by my own, like Google Chrome, or Office Suite

  • Can you block a ipod 8gb thats been stolen

    Hi all is it possible to block or something to a stolen ipod touch, I did not set up mobileme as did not know about this until to late can anyone help me please,

  • Movement of Objects

    Hi there, I'm looking for a way to add movement/animation of an object. For Example I want to move an object from 1 point in the slide to another w/out it leaving the slide itself. Meaning, I dont want to enter/exit the slide. Just custom movement. 1