Beans and Servlets.

java.lang.NullPointerException
at melon.servlets.GetStatsServlet.buildContent(GetStatsServlet.java:33)
at melon.servlets.MelonServlet.processRequest(MelonServlet.java:46)
at melon.servlets.MelonServlet.doPost(MelonServlet.java:79)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
I'am not vey clever at null pointers but isn't this error actually pointing to HttpServlet? Please help, I've struggled with this error for weeks :)
-Mogul 76

look at this method: buildContent of the class GetStatsServlet
You have something set to null and your code must be trying to use this null value.
Paste the code for this Method pls!!!
:)

Similar Messages

  • Strange behavior with entity beans and servlets in a cluster

    We have 2 WebLogic 4.5.1 servers in a cluster with none of the Service
              Packs installed. When a client uses the deployed entity beans or
              servlets they work every other time. The times they do not work nothing
              happens. No exceptions, no responses to the client ( i.e. HTTP 404s ),
              nothing. I suspect something in the cluster setup since we do not have
              these same problems on non-clustered entity beans or servlets. We have
              made sure all the entity beans have the Shared Database flag set on and
              added the delayUpdatesUntilEndOfTx false to the enviroment of the DD.
              That didn't fix the problem. Any ideas?
              Thanks in advance,
              Dallas Dempsey
              DEM - Houston, TX
              

    Do you have log files?
              - Prasad
              Chris Dempsey wrote:
              > We have 2 WebLogic 4.5.1 servers in a cluster with none of the Service
              > Packs installed. When a client uses the deployed entity beans or
              > servlets they work every other time. The times they do not work nothing
              > happens. No exceptions, no responses to the client ( i.e. HTTP 404s ),
              > nothing. I suspect something in the cluster setup since we do not have
              > these same problems on non-clustered entity beans or servlets. We have
              > made sure all the entity beans have the Shared Database flag set on and
              > added the delayUpdatesUntilEndOfTx false to the enviroment of the DD.
              > That didn't fix the problem. Any ideas?
              >
              > Thanks in advance,
              > Dallas Dempsey
              > DEM - Houston, TX
              

  • Send data from bean to servlet and get results back to bean

    Hi,
    I'm new to this helpful forum and, as long as I'm practicing with JFS and Java Beans and Servlets, I really need some help about the following crappy issue.
    I made a JSP login page called "LoginPage.jsp" (using "Visual Web JSF Page" tool in NetBeans 6.0), and the action associated to the "Login" button pression is defined in the associated Java Bean "LoginPage.java":
    Code from "LoginPage.jsp":
    <webuijsf:button actionExpression="#{LoginPage.loginButton_action}" binding="#{LoginPage.loginButton}" id="loginButton" primary="true" style="height: 24px; left: 383px; top: 192px; position: absolute; width: 96px" text="Login"/>
    Code from "LoginPage.java":
    public String loginButton_action()
        if (usernameField.equals("guest") && passwordField.equals("guest")) // this control should be done by a servlet, not here!
            return "loginOK"; // this is the outcome for faces-config.xml that will lead to a "Welcome.jsp" page
        else
            return "loginERROR"; // this is the outcome for faces-config.xml that will lead to a "Error.jsp" page
    ...Now, the problem is that the username and password control should not be done by the bean itself, but by a servlet (call it "LoginServlet.java").
    In a few words, what I mean is that once the user writes username and password and presses the "Login" button, the called "loginButton_action()" forwards all the needed data to the servlet "LoginServlet.java", the servlet does the complete checks about login validity then prepares the result (it could be a string reporting "OK" or whatever else) and send it back to the bean "LoginPage.java", so that the flow can continue.
    My problem is that I absolutely don't know how to make a bean and a servlet communicate in both ways and respectively exchange data.
    Thanks in advance for any help, it will really be appreciated.

    Google for passing values in request and session.

  • Hi frnds i want to help in servlet,java bean and JSP

    hi friends i'm right now in M.SC(IT) and i want to do project in SERVLET,,JAVA BEANS and JSP ,
    so pls give me a title about that
    NOTE: I develop a project in group(2 persons there)
    my email id is : [email protected] , [email protected] , [email protected]

    You cannot pair your iPod to a cell phone, so forget about it.
    The only way you can get free WiFi is to hang out at a Denny's, a Starbucks, or a truck stop, and I don't think your parents would approve....

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • Deploying a WAR file containing .jsp and servlets (also uses JNI)

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

  • Beans and classes

    Is it possible to use bean not just as storage but as a class- to use methods other then get or set on it? I added a little method that just prints out all of the parameters but what I get is
    javax.servlet.ServletException: foo.Creature.stats()Ljava/lang/String;
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
    at org.apache.jsp.index1_jsp._jspService(index1_jsp.java:77)
    (jsp page is index1.jsp)
    and in that index1_jsp.java file line 77 looks like
    if (pageContext != null) pageContext.handlePageException(t);
    which doesnt tell me a whole lot. So how do I use methods on beans and how do I make errors make more sence?

    Sure you can call other methods of your bean.
    How are you invoking it? How does it print out the 'parameters'?
    What you might try is wrapping it in your own exception code to see what happens.
    You will need to import java.io.PrintWriter to get this to work.
    <%@ page import="java.io.PrintWriter" %>
    <%
    try{
      call your method...
    catch (Throwable t){
    %> 
      ERROR IN MY CODE HERE <br>
      <pre><% t.printStackTrace(new PrintWriter(out));%></pre>
    <%
    %>(Yes I know this code is ugly, but it does work for me)

  • RPC web service session beans and local interfaces

    I am wondering if it is possible to use EJB 2.0's local
    interface (vs remote interface) with 6.1's RPC web service
    session beans. Since WLS generates the SOAP servlet that
    invokes the RPC session bean and I do not find
    a way to some how tell SOAP servlet to use local interface to
    get the session bean's local home interface, I am not sure
    this can be done.
    Any comments would be appreciated.
    Thanks.
    Peter

    Ta. Thanks for the info.
    Any idea when Local I/F support is due?
    -Nick
    "Neal Yin" <[email protected]> wrote:
    >
    "Nick Minutello" <[email protected]>
    wrote
    in message news:3d4413a4$[email protected]..
    I was just about to post the very same question - but for WLS 7.0.0.1.
    There are essentially two questions:
    1) (from a functional perspective)
    Can I expose Local Interfaces as SOAP using the auto-generation(servicegen ant
    tasks)?Local Interfaces support is coming.
    2) (from a performance perspective)
    Does the generated SOAP implementation go via the (expensive) RemoteInterface
    (ie marshalling) - or is the RMI marshalling optimised out (by setting<enable-call-by-reference>true</>)?
    You can set this option by yourself on your EJB. Web service runtime
    doesn't
    do any magic in this area.
    Regards,
    Nick
    "Peter" <[email protected]> wrote:
    I am wondering if it is possible to use EJB 2.0's local
    interface (vs remote interface) with 6.1's RPC web service
    session beans. Since WLS generates the SOAP servlet that
    invokes the RPC session bean and I do not find
    a way to some how tell SOAP servlet to use local interface to
    get the session bean's local home interface, I am not sure
    this can be done.
    Any comments would be appreciated.
    Thanks.
    Peter

  • First use of jsp and java bean and "Unable to compile class for JSP" error

    Hi,
    I am trying to create my first jsp + java bean and I get a basic error (but I have no clue what it depends on exactly). Tomcat seems to cannot find my class file in the path. Maybe it is because I did not create a web.xml file. Did I forgot to put a line in my jsp file to import my bean?
    Thank you very much for your help.
    Here is my error:
    An error occurred at line: 2 in the jsp file: /login.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    /usr/local/tomcat/jakarta-tomcat-5/build/work/Catalina/localhost/test/org/apache/jsp/login_jsp.java:43: cannot resolve symbol
    symbol : class CMBConnect
    location: class org.apache.jsp.login_jsp
    CMBConnect test = null;
    I only have this in my directory:
    test/login.jsp
    test/WEB-INF/classes/CMBConnect.java
    test/WEB-INF/classes/CMBConnect.class
    Do I need to declare another directory in classes to put my class file in it and package my bean differently?
    Here is my login.jsp:
    <%@ page errorPage="error.jsp" %>
    <jsp:useBean id="test" type="CMBConnect" scope="session" />
    <html>
    <head>
    <title>my test</title>
    </head>
    <body>
    <h3>Login information</h3>
    <b><%=session.getValue("customerinfo.message")%></b>
    <form> ....... </form>
    </body>
    </html>
    and here is my CMBConnect.java:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class CMBConnect
    public CMBConnect () { }
    public String openConnection(String id, String password) {
    String returnText = "";
    try {
    Connection con = null;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection("jdbc:oracle:thin:@myserver.abc.com:1521:TEST", id, password);
    if(con.isClosed())
    returnText = "Cannot connect to Oracle server using TCP/IP...";
    else
    returnText = "Connection successful";
    } catch (Exception e) { returnText = returnText + e; }
    return returnText;
    Thanks again!

    Thanks for you help
    I created the package and I get this error this time:
    javax.servlet.ServletException: bean test not found within scope
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:822)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:755)
         org.apache.jsp.login_jsp._jspService(login_jsp.java:68)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:268)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:277)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:223)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

  • Using java bean in servlet

    Hi,
    I have a problem in getting the values from simple bean to servlet. The project has one html form. When the user click on the submit button one jsp will be invoked which calls a bean program to validate the user data for required fields. Based on the result, jsp program forward the control to a servlet which stores the data in a database. Otherwise another jsp is called to inform the user to fill in the required data.
    My problem is how to send the data from bean to servlet?
    The snippet of jsp that calls bean is like this :
    <%!
    %>
    <jsp:useBean id="formHandler" class = "subFormBean" scope="request">
    <jsp:setProperty name="formHandler" property="*"/>
    </jsp:useBean>
    <%
    if (formHandler.validate()) {
    %>
    <jsp:forward page="subscriberRegistration"/>
    <%
    } else {
    %>
    <jsp:forward page="retry.jsp"/>
    <%
    %>
    And the snippet of the bean is like this :
    public boolean validate() {
    boolean bool=true;
    if (subname.equals("")) {
    errors.put("subname","Please enter your Name");
    subname="";
    bool=false;
    public subFormBean() {
    subname="";
    public String getSubName() {
    return subname;
    public void setSubName(String sname) {
    subname =sname;
    The servlet which is to receive the data is like this :
    public class subscriberRegistration extends HttpServlet{
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    subFormBean sfb = new subFormBean();
    sfb.setSubName(subname);
    But I'm getiing error while trying to compile the servelet saying that no variables found - sfb, subname etc.
    Please let me know how to invoke the bean from servlet. I want to use servlet to instead of jsp to insert records into database. How can i do this? Please help me. Thanks in advance.

    Hi Tolls,
    Sorry, I'll give a bigger snippet of the prog.code below :
    public class subscriberRegistration extends HttpServlet{
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    subFormBean sfb = new subFormBean();
    sfb.setSubName(subname);
    sfb.setSubAddress(subaddress);
    sfb.setSubCity(subcity);
    sfb.setSubState(substate);
    sfb.setSubCntry(subcntry);
    sfb.setSubPin(subpin);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException{
    response.setContentType("text/html");
    PrintWriter pw = response.getWriter();
    Class.forName("oracle.jdbc.driver.OracleDriver");
    connection = DriverManager.getConnection(connectionURL,"scott","tiger");
    stmt = connection.createStatement();
    rs = stmt.executeQuery("SELECT subid_seq.NEXTVAL FROM DUAL");
    while(rs.next()) {
    String subno = rs.getString("NEXTVAL");
    PreparedStatement pst = connection.prepareStatement("insert into eps_subscriber(eps_subno, eps_subname, eps_subaddress, eps_subcity, eps_substate, eps_subcntry, eps_subpin, eps_subphno, eps_subemailid, eps_subuserid, eps_subpwd) values(?,?,?,?,?,?,?,?,?,?,?)");
    pst.setString(1,subno);
    pst.setString(2,sfb.subname);
    pst.setString(3,sfb.subaddress);
    pst.setString(4,sfb.subcity);
    pst.setString(5,sfb.substate);
    pst.setString(6,sfb.subcntry);
    pst.setString(7,sfb.subpin);
    I'm validating the form data in beans program. Servlet is used to insert records into the database. So, i'm trying to capture data from the bean. How to capture the data from the bean to servlet? Or should I get it from the form fields directly? The servlet worked well when data was captured directly from html form fields. Please help me to fix this. Thanks in advance.

  • Signed Java Beans and Native IE JVM

    From a forms web app I need to get some client machine and do
    file uploads. There is great sample code for doing this. I tried
    using the GetClientInfo sample and it works fine in Forms
    Builder and it works fine with JInitiator. But I need it to work
    with the Native IE JVM.
    I cabbed and signed the bean and included a PARAM
    NAME="cabinets" VALUE="f60all.cab, getclientinfo.cab" in the
    APPLET tag. I do not get a security exception and the form seems
    to recognize the bean (the bean area is all blue). But I never
    get results.
    Has anyone gotten the sample beans to work with Native IE?
    What's the trick?

    The only thing that has been changed is
    IE50=native instead of IE50=JInitiator
    Is it correct that cabbase is empty in case of native settings?
    The settings are:
    <APPLET CODEBASE="/forms60java/"
    CODE="oracle.forms.engine.Main"
    WIDTH="496"
    HEIGHT="553">
    <PARAM NAME="cabbase" VALUE="">
    <PARAM NAME="serverPort" VALUE="9000">
    <PARAM NAME="serverHost" VALUE="yyy.com">
    <PARAM NAME="serverURL" VALUE="/servlet/lservletxxx?ifcfs=/servlet/f60servlet?config=xxx">
    <PARAM NAME="connectMode" VALUE="HTTP">
    <PARAM NAME="serverArgs"
    VALUE="module=Start01.fmx userid= ">
    <PARAM NAME="separateFrame" VALUE="true">
    <PARAM NAME="splashScreen" VALUE="no">
    <PARAM NAME="background" VALUE="no">
    <PARAM NAME="lookAndFeel" VALUE="generic">
    <PARAM NAME="colorScheme" VALUE="teal">
    <PARAM NAME="serverApp" VALUE="hsd65reg">
    </APPLET>

  • Using Beans in Servlets

    Im using a servlet that accesses a java bean within a session in order to display all the contents within the bean. The code is shown below:
    HttpSession session = request.getSession();
    ItemBean bean = new ItemBean();
    bean.setProductID(results.getString("ProductID")); bean.setProductDescription(results.getString("ProductDescription")); bean.setProductName(results.getString("ProductName")); bean.setProductPrice(results.getString("ProductPrice"));
    bean.setQuantity(Quantity);
    ItemBeans item = (ItemBeans)session.getAttribute("basket");
    item.addItemBean(bean);
    I use a jsp page that uses this bean to display the items. Once all the items have been displayed on the page, the user clicks on a button and this calls another servlet which should take all the items in the bean and store them in a database. Does anyone know how to do this?
    Thanks.

    How do I actually store the information in the bean
    to my database?
    For example, the bean holds details of product name,
    description, price etc. How do I get all these
    details and store them on the database?
    All my other servlets simply retrieve one pair of
    information using request.getParameter(); and then
    run a query which adds this parameter to the
    database. But how do I do it for a bean?Very similar. Instead of using request.getParameter, you get the session. You get the bean from the session. You get<properyName>() from the bean. You run the query.

  • Java app with web service and servlets

    Hi. I intend to make a java application which exposes some methods as a web service and as jsp/servlets. It's core functionality is not really web centric, but its more a java app with a web tier. I am not sure about how the architecture of such a system would look like using the java platform. I currently see three options:
    1. Run everything in a servlet container like tomcat. I hesitate to do this because i would be putting a lot of functionality which isn't about the web into a servlet container. Also, I have a lot of application scope data that is maintained and shared by all servlets/web services. However, it would be really easy just to put everything into tomcat and use ServletContext to maintain some global objects.
    2. Use a Java EE to seperate application/business logic and data access into session beans and entity beans. I hesitate to this because it seem a bit overkill because the system isn't very big or complex right now. It also means that I would have to learn to use EJB's instead of just using some POJOs.
    3. Run the web tier in a servlet container and the main app in a separate JVM, and then connect the tier by sending serialized objects over TCP sockets. I don't like writing network code but at least there is some separation of the tiers.
    What would you do? Maybe I have overlooked a much better solution to the problem?
    Let me just say that the system is the product of a student project spanning one semester, so it's important to choose the RIGHT solution (architectural-wise) instead of the something quick and dirty that is hard to defend.

    jschell wrote:
    Run everything in a servlet container like tomcatTomcat is a JEE container.Now I am confused. Maybe you mean Glassfish? Tomcat is definitely a web container(?).
    Let me just say that the system is the product of a student project spanning one semester, so it's important to choose the RIGHT solution (architectural-wise) That pretty much makes it impossible then.
    1. A "Right" solution is generally only proven by time.
    2. It requires a great deal of knowledge about the business domain.Yeah, you are right. Let be try to rephrase it. What solution (pattern) would be considered the most common or appropriate when you have a Java App and want to expose a few methods as a website and web service?
    I hesitate to do this because i would be putting a lot of functionality which isn't about the web into a servlet container. Also, I have a lot of application scope data that is maintained and shared by all servlets/web servicesHuh? Do you already have an exposed web service? If you already have a server which other clients communicate then where does this functionality that you don't want to be tomcat running now? Or where do you think that you want to run it? And if you are or do run it somewhere else then tomcat could access it the same way any other client accesses that server.Sorry, that sentence was written badly. I don't have anything right now. What I meant to write was that I will have a lot of application scope data, objects that are kept in memory as long as the server is running, shared by multiple servlet instances.

  • Instantiating bean in Servlet

    Hi All
    I have written a bean that fetches data from another java class. My Servlet instantiates that bean and pass that object reference to another Java class, which is multi-threaded. One thread of that class calls another method of another object using that object reference. so, in that way the object reference of that bean (which is created by the servlet) is passed all over the application and fetches data from there to show in the Servlet.
    Now my question is, as Servlet is multithreaded by default, it should create an instance of that bean everytime the servlet is accessed (not by calling from that servlet or any other servlets/JSPs)by different users. And by this way every servlet should have their own bean instances. In my case, when I am running that servlet in my localhost it works fine but at the same time when I try to invoke that servlet again from another browser it passes the bean object reference as null. I dont really understand that. Currently I am creating the bean instance in the class definition. I tried to create the instance in init() method but the problem remains same. If my approach is wrong then where should I create the bean instance.
    Thanks in advance.
    Regards
    Anirban

    Thanks very much.
    I have no service method. I have doGet() and doPost() method. doGet is called just once to create the login screen in every session. doPost handles the form data and it is called several times.
    should I create the bean instance in doGet method then? I have to pass that object reference as an object array in that method parameter. where should I initialize that object array and create the instance of the bean and pass the array to another method. I am passing that object reference to another java class method in doget() method.
    Cheers!!
    Anirban

  • Sharing data between a bean and a jsp

    I have a bean that is being used as a helper class for a jsp page. I can call functions in the bean and display what is returned but I can't test the state of the bean in the jsp page. Is this possible?
    my code is below:
    jsp: a form posts info to this page
    <HTML>
    <BODY>
    <jsp:useBean id='portal' class='portal.portal'/>
    <%-- set the username and password --%>
    <jsp:setProperty name="portal" property="*" />
    <jsp:getProperty name="portal" property="dbconnection"/>
    <Center>
    <H1>Welcome to the Portal
    <jsp:getProperty name="portal" property="firstName"/>
    </H1>
    <br>
    <table border="0">
    <%-- while loop grabs all the services --%>
    <%-- case tests for special services (links) --%>
    <%
    String url = "";
    int ServiceID = 0;
    //I CAN'T PULL THE VALUES FOR THESE VARIABLES SO THE WHOLE WHILE LOOP IS SKIPPED!
    while (url.length() != 0)
    switch (ServiceID)
    case 69:
    %>
    <tr valign="top" height="45">
    <td>
    <center>
    " TARGET="new_window"><IMG SRC="images\MEDS TAPE LOG.gif" BORDER=white></A><br>
    </center>
    </td>
    </tr>
    <%
    break;
    case 41:
    %>
    <tr valign="top" height="45">
    <td>
    <center>
    <A HREF="<jsp:getProperty name="portal" property="url"/>" TARGET="new_window"><IMG SRC="images\Lan Support Website.gif" BORDER=white></A><br>
    </center>
    </td>
    </tr>
    <%
    break;
    case 1:
    %>
    <tr valign="top">
    <td>
    <center>
    <form name="loginfrm" action="http://204.104.185.139/pls/WLOG/login.ValidateUser" method="post" target=_parent>
    <INPUT TYPE=hidden NAME=TXTUSERNAME VALUE="<jsp:getProperty name="portal" property="name"/>">
    <INPUT TYPE=hidden NAME="TXTPASSWORD" VALUE="<jsp:getProperty name="portal" property="password"/>">
    <input TYPE="submit" VALUE="<jsp:getProperty name="portal" property="serviceName"/>" style="width: 120px;" >
    <input type="reset" name="reset" value="">
    </Form>
    </center>
    </td>
    </tr>
    <%
    break;
    default:
    %>
    <tr valign="top">
    <td>
    <center>
    <Form method='post' action='<jsp:getProperty name="portal" property="url"/>' name='loginfrm'>
    <INPUT TYPE=hidden NAME="TXTPASSWORD" VALUE="<jsp:getProperty name="portal" property="password"/>">
    <INPUT TYPE=hidden NAME="TXTUSERNAME" VALUE="<jsp:getProperty name="portal" property="name"/>">
    <INPUT TYPE=hidden NAME="firstname" VALUE="<jsp:getProperty name="portal" property="firstName"/>">
    <INPUT TYPE=hidden NAME="lastname" VALUE="<jsp:getProperty name="portal" property="lastName"/>">
    <INPUT TYPE=hidden NAME="id" VALUE="<jsp:getProperty name="portal" property="userID"/>">
    <INPUT TYPE=hidden NAME="role" VALUE="<jsp:getProperty name="portal" property="roleID"/>">
    <input type='submit' name='submit' value='<jsp:getProperty name="portal" property="serviceName"/>'>
    </Form>
    </center>
    </td>
    </tr>
    <%
    break;
    %>
    <jsp:getProperty name="portal" property="nextForm"/>
    <%
    %>
    </table>
    </Center>
    </Body>
    </Html>
    here is the bean:
    //bean for portal
    package portal;
    import java.io.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.util.Enumeration;
    import java.sql.*;
    import java.util.*;
    public class portal {
    private ResultSet userInfo;
    private Statement stmt;
    private String pw;//password from the database
    private String FirstName;
    private String LastName;
    private String UserName=""; //network login name
    private String UserPassword="";//password supplied by the form
    private int UserID; // temp variable while pulling the services from the databases
    private int RoleID; // temp variable while pulling the services from the databases
    private String ServiceName=""; //temp variable while pulling the services from the database
    private int ServiceID;
    private String url ="";
    //String Message=""; //testing
    private String Message2=""; //string that sends the correct html back to the jsp
    public int getServiceID(){
    return ServiceID;
    public void setName(String Name){
    UserName = Name;
    public String getName(){
    return UserName;
    public void setPassword(String Password){
    UserPassword = Password;
    public String getPassword(){
    return UserPassword;
    public String getFirstName(){
    return FirstName;
    public String getLastName(){
    return LastName;
    public String getUrl(){
    return url;
    public int getUserID(){
    return UserID;
    public int getRoleID(){
    return RoleID;
    public String getServiceName(){
    return ServiceName;
    public String getDbconnection() {
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    DriverManager.setLoginTimeout(60);//time out after 1 min.
    Connection con = DriverManager.getConnection("jdbc:odbc:Portal");
    stmt = con.createStatement();
    String query = "SELECT EMP_TABLE.EMP_PASS, MGR_SERVICES.SERVICE_ID,";
    query = query +" MGR_SERVICES.DEFAULT_URL, EMP_TABLE.EMP_USER_ID, *";
    query = query +"FROM (EMP_TABLE LEFT JOIN MGR_USER_SERVICES ON";
    query = query +" EMP_TABLE.EMP_USER_ID = MGR_USER_SERVICES.USER_ID)";
    query = query +" LEFT JOIN MGR_SERVICES ON MGR_USER_SERVICES.SERVICE_ID =";
    query = query +" MGR_SERVICES.SERVICE_ID WHERE (((EMP_TABLE.EMP_LAN_ID)='" + UserName+ "'))";
    //String query = "SELECT EMP_TABLE.EMP_PASS, MGR_SERVICES.SERVICE_ID,";
    //query = query +" MGR_SERVICES.DEFAULT_URL, EMP_TABLE.EMP_USER_ID, *";
    //query = query +"FROM (EMP_TABLE LEFT JOIN MGR_USER_SERVICES ON";
    //query = query +" EMP_TABLE.EMP_USER_ID = MGR_USER_SERVICES.USER_ID)";
    //query = query +" LEFT JOIN MGR_SERVICES ON MGR_USER_SERVICES.SERVICE_ID =";
    //query = query +" MGR_SERVICES.SERVICE_ID WHERE (((EMP_TABLE.EMP_LAN_ID)='landwla'))";
    //String query = "SELECT * FROM EMP_TABLE WHERE EMP_LAN_ID ='landwla'";
    userInfo = stmt.executeQuery(query);
    if(userInfo.next())
    pw = userInfo.getString("EMP_PASS");
    if (UserPassword.equals(pw))
    //Message = "Your logged in";
    //Message = Message + "Luke you sly devil";
    FirstName = userInfo.getString("EMP_FIRST");
    LastName = userInfo.getString("EMP_LAST");
    UserID = userInfo.getInt("EMP_USER_ID");
    RoleID = userInfo.getInt("ROLE_ID");
    url=userInfo.getString("DEFAULT_URL");
    ServiceName = userInfo.getString("SERVICE_NAME");
    ServiceID = userInfo.getInt("Service_ID");
    else
    Message2 = "<Script Language=JavaScript>";
    Message2 = Message2 + "alert('Your Password Information is incorrect');";
    Message2 = Message2 + "window.location.href = 'Login.html'";
    Message2 = Message2 + "</Script>";
    else
    Message2 = "<Script Language=JavaScript>";
    Message2 = Message2 + "alert('Your Login Information is incorrect');";
    Message2 = Message2 + "window.location.href = 'Login.html'";
    Message2 = Message2 + "</Script>";
    catch (InstantiationException i)
    {return (i.toString());}
    catch (ClassNotFoundException c)
    {return (c.toString());}
    catch (SQLException sql)
    {return (sql.toString());}
    catch (Exception e)
    {return (e.toString());}
    return Message2;
    public String getNextForm() {
    try
    url="";
    ServiceName="";
    if(userInfo.next())
    url=userInfo.getString("DEFAULT_URL");
    ServiceName = userInfo.getString("SERVICE_NAME");
    RoleID = userInfo.getInt("ROLE_ID");
    ServiceID = userInfo.getInt("Service_ID");
    catch (SQLException sql)
    {return (sql.toString());}
    return Message2;

    Of course you can.
    <%
    String url = protal.getUrl();
    %>

Maybe you are looking for

  • 1 of several errors that continue to occur after yosemite install

    Process: cloudd [1074] Path: /System/Library/PrivateFrameworks/CloudKitDaemon.framework/Support/cloudd Identifier: cloudd Version: 259.2.3 (259.2.3) Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: cloudd [1074] User ID: 502 Date/Time:

  • Save portion of a waveform chart

    First of all I acquire 2 voltage signals and save them in a file. The next thing I have to do is to read that file and show a portion of the waveform in a picture inside the page of a tab control, so each page of the tab control has a picture of a di

  • Servlet group is fine, but why delete the JSP group?

    Dear WebLogic support,           You took one step forward, and one step backwards.           Creating the servlet newgroup was the right thing to do.           BUT DELETEING THE 'JSP' GROUP WAS NOT!           JSP has it's own issues, which does dese

  • Everything disappeared...PLS help :)

    Hi everyone, Today I shut my computer and when i opened it again, everything on my desktop disappeared but the application files are still the same, but the background and the desktop changed i dont know what happened, even my songs and the files in

  • Static DNS record deleted automatically- Windows 2008 R2 SP1

    Hi, I have scoured the Interweb and tried all suggestions to no avail for this one. Here's the scenario: My client has a Windows 2008 R2 SP1 (Windows 2003 domain/forest functional level) server which is a DC and DNS server. The problem is that a DNS