Question on Method 'getRequestDispatcher'

Hi all,
I am wondering is it a good way to forward a request in try block but close database connection in the finally block. Below is the code snippet for your reference:
Connection conn = null;
try {
    conn = initConn();
    boolean bool = validateAcct();
    if (bool) {
        getServletContext().getRequestDispatcher("/acctProfile.jsp")
    } else {
        getServletContext().getRequestDispatcher("/error.jsp")
} catch (Exception e) {
    // Empty block here
} finally {
    if (!(conn == null || conn.isClosed())) {
        conn.closed();
        conn = null;
}The codes in finally block is executed even the forward action is invoked in try block. So, is this a good way to handle database connection without resulting connection leaking issue in application server (IBM Websphere App Server)? Hope to get some advise from this forum.
Thank you.

Other bad tastes in this code:
1. Connection conn = null;
try {
    conn = initConn();in case <tt>initConn()</tt> fails there is no meaningfull way to handle this, so let the Exception comming from <tt>initConn()</tt> simply fall through this method:
Connection conn = initConn();
try { 2. boolean bool = validateAcct();is a meaningless variable name. Also since there is only onlne place where bool is read ist's not needed here at all.
There could be only one reason to have a variable here and this is if the method <tt>validateAcct()</tt> cannot be renamed to <tt>isAcctValid()</tt>. In this only one case a variable <tt>boolean isValidateAcct = validateAcct()</tt> meight be accepted.
3. } finally {   
    if (!(conn == null || conn.isClosed())) { When following point 1 conn cannot be null here ~(provided that <tt>initConn()</tt> has been carefully coded to either return a working connection or throw an exception).~ Also there is nothing within the try block that closes the connection. So the entire if is not needed.
4. conn = null; The reference <tt>conn</tt> is defined within the scope of the method. So if the method ends the reference will be destroyed. So there is no need to explicitly set the reference to null .
bye
TPD

Similar Messages

  • A question on methods and parameters.

    Hey guys, it's my first time posting here. I'm very new to Java, and did a bit of C++ prior to Java. I had a question on methods and parameters. I don't quite understand methods; I know that they can be repeated when called, but thats almost about it. I also know that a program must have one class that holds the main method. What I truly, truly don't understand about methods is what parameters are. I know they go in the parentheses, and that's it. Could you please explain what they are? I truly appreciate it. Thanks to all in advance. Regards, Michael

    Taking an example :
    Suppose you are calculating area of rectangle you need two inputs one is length and breadth.Area = l X b where l = length, b = breadth
    So your method, say, calculateAreaOfRectangle(int length, int breadth) will have two input parameters as arguments.
    System.out.println("Area of rectangle:"+calculateAreaOfRectangle(40,30);
    public int calculateAreaOfRectangle(int length, int breadth) {
    int Area;
    Area = length * breadth;
    return Area;
    So if you call this method then the output will be returned as 120.
    Parameters of a method are just the input variables needed for the method to process for any calculations or anything useful.
    And we cant have methods inside main method in Java. It is against the java syntax and if you do, it will throw a syntax error.

  • HT5787 i forgot Icloud password and security question what method i can use to reset it is ther any or what i am still using iphone but my icloud is disabled for to many atempts what now how to rest the password

    i forgot Icloud password and security question what method i can use to reset it is ther any or what i am still using iphone but my icloud is disabled for to many atempts what now how to rest the password

    Hi bekimlorini,
    Thanks for visiting Apple Support Communities.
    You may find this article helpful with resetting your security questions:
    Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/HT5312
    If you're not able to receive email to your rescue email address, you may need to contact iTunes Store Support:
    You'll need to contact iTunes Store support to have your questions and answers reset.
    All the best,
    Jeremy

  • Question: Best method for mounting drives at log-in time?

    I would like to know what others consider the best method for mounting drives at log-in time is? I can see a few methods such as start-up items on the client, start-up items on the server to managed users and possibly a start-up script. One wrinkle in the scenario is that users can log-in directly to the server so the method should allow that to happen gracefully. Thanks in advance for your help.

    Hi Bigsky,
    You are asking some really fundamental questions that require quite a lot of explanation. Luckily Apple has some great documentation on their server software.
    You will be able to find your answers here by diggin in a bit:
    http://www.apple.com/server/documentation/
    Good Luck!
    Dual 2.0Ghz G5   Mac OS X (10.4.3)  

  • Simple Question Calling methods from Java files through JSP without JVM

    Hi.
    I've got a simple question (forigve my newbieness)...
    If I'm running Tomcat can I exectue a method in a compiled Java file from a JSP page without having the JVM installed on the server?
    Any thoughts or additional comments would be appreciated.
    Many thanks.

    No... but that's because you can't run Tomcat without
    a JVM installed on the server.
    If you are running Tomcat, you are running a JVM for
    the JSP pages to run in, in which case, yes, the JSP
    pages can call the other Java code... as long as it's
    in the classpath.Thanks a lot for the replies.
    So just to check, if I sign up with a hosting company that offers Tomcat then the JVM will be installed on the server and I can call other Java code as long as it's in the classpath?
    I just want to make sure before I sign up with a hosting company =D
    Thanks again!

  • Question on Method interface

    Hi
    I've the following method def:
       METHODS : METH1 IMPORTING INPUT1 TYPE I  
                                                                  INPUT2 TYPE REF TO  CL_1.
    where CL_1 is the class withing where the method is defined.
    Question is, what is this kind of definition and whats the use in real time implementation?
    thkx
    P.S

    It can also be used in generic calls. Suppose we have vehicle class.
    CLASS lcl_vehicle DEFINITION.
       PUBLIC SECTION.
          METHODS: add_vehicle IMPORTING l_veh TYPE REF TO lcl_vehicle,
                            estimate_fuel.
          "table storing vehicles
          DATA: BEGIN OF it,
                       vehicle TYPE REF TO lcl_vehicle,
                     END OF it,
                     wa LIKE LINE OF it.
    ENDCLASS.
    CLASS lcl_vehicle IMPLEMENTATION.
        METHOD add_vehicle.
            wa-vehicle = l_veh.
            APPEND wa TO it.
        ENDMETHOD.
        METHOD estimate_fuel.
            LOOP at IT into WA.
               wa-vehicle->estimate_fuel( ).              "here we can call same method of different subclasses with different implementation
            ENDLOOP.
        ENDMETHOD.
    ENDCLASS.
    Now we create to subclasses.
    CLASS lcl_plane DEFINITION INHERITING FROM lcl_vehicle.
       PUBLIC SECTION.
          METHODS estimate_fuel REDEFINITION.
    ENDCLASS.
    CLASS lcl_ship DEFINITION INHERITING FROM lcl_vehicle.
       PUBLIC SECTION.
          METHODS estimate_fuel REDEFINITION.
    ENDCLASS.
    Two different vehicles will redefine an estimate_fuel method as each has to take different factors into account when tanking up.
    We would like to handle both plane and ship from one point. For this we add our new vehicles to the table of lcl_vehicle class.
    DATA: r_vehicle TYPE REF TO lcl_vehicle,
              r_plane    TYPE REF TO lcl_plane,
              r_ship      TYPE REF TO lcl_ship.
    CREATE OBJECT: r_vehicle, r_plane, r_ship.
    "add all vehicles to the table
    r_vehicle->add( r_plane ).
    r_vehicle->add( r_ship ).
    "Now we can perform generic call
    r_vehicle->estimate_fuel( ).  "this will call same method of two subclasses with different implementation, from one point
    It would be easy now to handle new vehicle
    CLASS lcl_motorbike DEFINITION INHERITING FROM lcl_vehicle.
       PUBLIC SECTION.
          METHODS estimate_fuel REDEFINITION.
    ENDCLASS.
    DATA: r_motorbike TYPE REF TO lcl_motobike.
    r_vehicle->add( r_motorbike ). "it is enough to add the vehicle, this already suits our model and appropriate method will be called for estimating fuel
    Regards
    Marcin
    Edited by: Marcin Pciak on Mar 23, 2009 10:17 PM

  • Question overloading method

    Hi, thanks for reading this message.
    Here is my problem.
    The context is Servlet and Jsp.
    I am developping and environnement for JSP developpers. This way I defined superclass for JSP pages that give people a basic behavior like getting access to the current user and some usefull methods to access session's parameters.
    This way I developpe a first abstract class with the fallowing method :
    protected void preProcessRequest(HttpServletRequest request, HttpServletResponse response) { ... }
    Now I have to subclass this method in a concreate class. This one will load the current user but, during this operation, an exception can be raised. This is normal. So the signature is now :
    protected void preProcessRequest(HttpServletRequest request, HttpServletResponse response) throws TinyException { ... } ;
    I andrestand why it can't be compiled but don't know how to do this an other way.
    Thank you

    But it's a more general question. When you define a
    framework, you don't know how it will be used. And
    what append if you subclass a method of a framework
    and your implementation throws an exception that
    was not in the abstract classes. Then the framework was badly designed. It needs to be loose enough to allow all sorts of implementations but strict enough to be useful.
    Have you ever wondered why the read & write of the abstract classes InputStream and InputStream throw IOException? Because otherwise it'd be impossible to declare to throw them in the subclasses, that's the way Java goes...
    So blame those who made the abstract class - you cannot declare to throw a totally unexpected exception from the subclass.
    But do note that while you cannot declare to throw the exception, nothing stops you from actually throwing it...

  • Question finding methods or documentation on methods

    Hi All,
    Where I can find all the functions or methods like SAPBWGetDataProviderDimensions ? This one I found on help.sap.com.
    Is there any good documentation on methods of classes like CL_RSR_WWW_ITEM_CHART...I can see classes methods of it using se84. but need more info.
    ANy Ideas ?
    Thanks in advance,
    GSM.

    Heider,
    Thank you for your information.
    Can I ask you one more question. I have one problem.
    A variable screen has profit center varible. User will enter one value on the profit center variable. In the template there is a combo. Which shows a ZINFOOBject values of a particular profit center. When the template is open it shows a graph and table for all the values of the profit center. If user needs to view the graph and table on ZInfoObject they will change the value in the drop down box.
    But my users are not happy with this. The way they want the solution is as soon as the webtemplate opens it show all the graphs for the number of values in the ZINFOOBJECT for a particular Profit Center.
    Eg. User enters profitcenter1 and it has 10 values in the ZINFOOBJECT, then in the web template it should show 10 graphs. If user enters profitcenter2 and it has 20 values for the ZINFOOBJECT, then the template should show 20 graphs.
    I am able to read each value within the profit center using the javascript. But I am unable to create the chart object in the javascript. I tried using document.write also.
    ANy ideas how this can be achieved ? Is it achievable by BSPs ? I don't know much about BSPs....
    Thank you very much for your input.
    GSM.
    The way I am showing on the information on a graph is,

  • Newbie Question - Best Method of Burning to DVD?

    Hi, I apologize in advance for how easy this question may be. I recently edited 20 minutes of footage for a friend and I'd like to have it burned to a DVD.
    In the past, I've burned plenty of video files with Nero but this project exports as a 4.3gb file, which won't fit on the DVD. I know next to nothign about codecs and such. The file type I used was Microsoft DV AVI and the Compressor was DV NTSC, frame size is 720 by 480 and pixel aspect ratio is D1/DV NTSC (0.9). I hope this helps... I believe these were chosen by default.
    I just want to be able to burn it to a DVD or export it as a manageable file size to burn later, without sacrificing too much quality, as the quality is already pretty poor.
    Thanks for any help :D

    Encore will compress the file to MPEG for you.

  • JSF newbie question - ServletException - Method not found

    I just started learning JSF (and JSP) by following the tutorial:
    JSF for nonbelievers: Clearing the FUD about JSF
    http://www-128.ibm.com/developerworks/library/j-jsf1/
    I'm getting a ServletException and I'm not sure why. Instead of starting the tutorial over, I'd like to learn what I'm doing wrong.
    The exception is:
    exception
    javax.servlet.ServletException: Method not found: [email protected]()
    root cause
    javax.el.MethodNotFoundException: Method not found: [email protected]()In the calculator.jsp page (a simple page with two form fields), I noticed that when I type CalcBean., my IDE (NetBeans) only autocompletes the class variables and neither of the methods (add and multiply). I quickly searched and someone suggested restarting the server. This did not fix my problem. I must be doing something completely wrong or I missed something in the tutorial. If you don't mind, please read the simple files below and see if you can spot anything wrong. Please keep in mind this is my first time using JSF (and JSP for that matter). If you can suggest a better newbie tutorial, please do! Thanks
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <context-param>
            <param-name>com.sun.faces.verifyObjects</param-name>
            <param-value>false</param-value>
        </context-param>
        <context-param>
            <param-name>com.sun.faces.validateXml</param-name>
            <param-value>true</param-value>
        </context-param>
        <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>client</param-value>
        </context-param>
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
            </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>/faces/*</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
         <welcome-file>
                index.jsp
            </welcome-file>
        </welcome-file-list>
    </web-app>
    faces-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- =========== FULL CONFIGURATION FILE ================================== -->
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
      <managed-bean>
        <description>
                    The "backing file" bean that backs up the calculator webapp
                </description>
        <managed-bean-name>CalcBean</managed-bean-name>
        <managed-bean-class>secondapp.controller.CalcBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
      <navigation-rule>
        <from-view-id>/calculator.jsp</from-view-id>
        <navigation-case>
          <from-outcome>success</from-outcome>
          <to-view-id>/results.jsp</to-view-id>
        </navigation-case>
      </navigation-rule>
    </faces-config>
    secondapp.controller.CalcBean.java
    package secondapp.controller;
    import secondapp.model.Calculator;
    * @author Jonathan
    public class CalcBean {
        private int firstNumber;
        private int secondNumber;
        private int result;
        private Calculator calculator;
        /** Creates a new instance of CalcBean */
        public CalcBean() {
            setFirstNumber(0);
            setSecondNumber(0);
            result = 0;
            setCalculator(new Calculator());
        public String add(int a, int b) {
            result = calculator.add(a,b);
            return "success";
        public String multiply(int a, int b) {
            result = calculator.multiply(a,b);
            return "success";
        // <editor-fold desc=" Accessors/Mutators ">
        public int getFirstNumber() {
            return firstNumber;
        public void setFirstNumber(int firstNumber) {
            this.firstNumber = firstNumber;
        public int getSecondNumber() {
            return secondNumber;
        public void setSecondNumber(int secondNumber) {
            this.secondNumber = secondNumber;
        public int getResult() {
            return result;
        public void setCalculator(Calculator calculator) {
            this.calculator = calculator;
        // </editor-fold>
    secondapp.model.Calculator
    package secondapp.model;
    * @author Jonathan
    public class Calculator {
        /** Creates a new instance of Calculator */
        public Calculator() {
        public int add(int a, int b) {
            return a+b;
        public int multiply(int a, int b) {
            return a*b;
    calculator.jsp
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <html>
        <head><title>Calculator Test</title></head>
        <body bgcolor="white">
            <h2>My Calculator</h2>
            <f:view>
                <h:form id="calcForm">
                    <h:panelGrid columns="3">
                        <h:outputLabel value="First Number" for="firstNumber" />
                        <h:inputText id="firstNumber" value="#{CalcBean.firstNumber}" required="true" />
                        <h:message for="firstNumber" />
                        <h:outputLabel value="Second Number" for="secondNumber" />
                        <h:inputText id="secondNumber" value="#{CalcBean.secondNumber}" required="true" />
                        <h:message for="secondNumber" />
                    </h:panelGrid>
                    <h:panelGroup>
                        <h:commandButton id="submitAdd" action="#{CalcBean.add}" value="Add" />
                        <h:commandButton id="submitMultiply" action="#{CalcBean.multiply}" value="Multiply" />
                    </h:panelGroup>
                </h:form>
            </f:view>
        </body>
    </html>

    In the future, please add some line breaks so I don't have to scroll horizontally to read your post.
    The problem is that the CalcBean.add/.multiply method is requiring two parameters. This method should be parameter-less. When talking about action methods, they should return String and not take any parameters.
    So, remove the parameters. You collect a firstNumber and a secondNumber from the user. These are the numbers you want to add (or multiply). Use those values (instead of the parameters) to calculate the result.
    The code changes aren't too complicated. I'd write them out for you, but you seem interested in learning (which is great by the way!). Let me know if you need more help on this.
    CowKing
    ps - I see more problems with the code, and I haven't given you all the answers. I know, I'm mean. You'll learn better if you try to fix things on your own first. I've just given you enough info to overcome the immediate issue. =)

  • Question about Methods

    I was wondering why i was not getting the right output. The program should give me..
    Storing : 0
    Checking Queue...
    Printing: 0
    Storing: 1
    Checking Queue...
    Printing:1
    etc...
    but instead all I get is...
    Storing :0
    Checking Queue..
    Storing:1
    Checking Queue...
    etc..
    Here is my Code:
    import java.util.ArrayList;
    public class Problem {
         public Storage storeMe = new Storage();
         public static void main(String[] args) {
              (new Thread(new Counter())).start();
              (new Thread(new Printer())).start();
    class Storage {
         ArrayList<Integer> queue = new ArrayList<Integer>();
         public int value;
         public int getValue() {
              if (queue.size() > 0)
                   return queue.remove(0);
              else
                   return -1;
         public void storeValue(int newvalue) {
              value = newvalue;
              queue.add(value);
    class Counter extends Problem implements Runnable {
         public void run() {
              int counter = 0;
              while (true) {
                   synchronized (this) {
                        try {
                             this.wait(1000L);
                        } catch (Exception e) {
                   System.out.println("Storing : " + counter );
                   storeMe.storeValue(counter);
                   counter++;
    class Printer extends Problem implements Runnable {
         public void run() {
              while (true) {
                   synchronized (this) {
                        try {
                             this.wait(1000L);
                        } catch (Exception e) {
                   System.out.println("Checking Queue ...");
                   int num = storeMe.getValue();
                   if (num != -1)
                        System.out.println("Printing : " + num);
    }I think the problem with my code is that in the Printer class, the storeMe.getValue() method is not updated. Or more accurately, the queue is not updated.
    Can anyone shed some light on this matter?
    thanks in advance..

    thanks for that info.
    this program worked fine using static variables and methods. But now I'm trying to do it without using static modifier with the exception of the main().
    I tried checking if there was an update on queue in the Printer class by changing the code to this:
    class Printer extends Problem implements Runnable {
         public void run() {
              while (true) {
                   synchronized (this) {
                        try {
                             this.wait(1000L);
                        } catch (Exception e) {
                   System.out.println("Checking Queue ...");
                   int num = storeMe.queue.size();
                        System.out.println("Queue size: " + num);
    }and I got this output:
    Storing : 0
    Checking Queue ...
    Queue size: 0
    Checking Queue ...
    Queue size: 0
    Storing : 1
    So basically, when the Printer Class runs and tries the to get the value from the storage class, it can't because the value read was 0, there was no queue. Does this mean that I have created a wrong object of the Storage class? or is there another way to call that method without using the static modifier?
    Specifically, How do I Try to call an instance of a method with its values still intact? Let's say I want My Printer Class to access the values inputted by the Counter Class in the Storage Class.

  • Question about method calling (Java 1.5.0_05)

    Imagine for example the javax.swing.border.Border hierarchy.
    I'm writing a BorderEditor for some gui builder, so I need a function that takes a Border instance and returns the Java code. Here is my first try:
    1 protected String getJavaInitializationString() {
    2     Border border = (Border)getValue();
    3     if (border == null)
    4         return "null";
    5
    6     return getCode(border);
    7 }
    8
    9 private String getCode(BevelBorder border) {...}
    10 private String getCode(EmptyBorder border) {...}
    11 private String getCode(EtchedBorder border) {...}
    12 private String getCode(LineBorder border) {...}
    13
    14 private String getCode(Border border) {
    15     throw new IllegalArgumentException("Unknown border class " + border.getClass());
    16 }This piece of code fails. Because no matter of what class is border in line 6, this call always ends in String getCode(Border border).
    So I replaced line 6 with:
    6     return getCode(border.getClass().cast(border));But with the same result. So, I try with the asSubClass() method:
    6     return getCode(Border.class.asSubClass(border.getClass()).cast(border));And the same result again! Then i try putting a concrete instance of some border, say BevelBorder:
    6     return getCode(BevelBorder.class.cast(border));Guess what! It worked! But this is like:
    6     return getCode((BevelBorder)border);And I don't want that! I want dynamic cast and correct method calling.
    After all tests, I give up and put the old trusty and nasty if..else if... else chain.
    Too bad! I'm doing some thing wrong?
    Thank in advance
    Quique.-
    PS: Sorry about my english! it's not very good! Escribo mejor en espa�ol!

    Hi, your spanish is quite good!
    getCode(...) returns the Java code for the given border.
    So getCode(BevelBorder border) returns a Java string that is something like this "new BevelBorder()".
    I want Java to resolve the method to call.
    For example: A1, A2 and A3, extends A.
    public void m(A1 a) {...}
    public void m(A2 a) {...}
    public void m(A3 a) {...}
    public void m(A a) {...}
    public void p() {
        A a = (A)getValue();
        // At this point 'a' could be instance of A1, A2 or A3.
        m(a); // I want this method call, to call the right method.
    }This did not work. So, i've used instead of m(a):
        m(a.getClass().cast(a));Didn't work either. Then:
        m(A.class.asSubClass(a.getClass()).cast(a));No luck! But:
        m(A1.class.cast(a)); // idem m((A1)a);Woks for A1!
    I don't know why m(A1.class.cast(a)) works and m(a.getClass().cast(a)) doesn't!
    thanks for replying!
    Quique

  • Question about methods in a class that implements Runnable

    I have a class that contains methods that are called by other classes. I wanted it to run in its own thread (to free up the SWT GUI thread because it appeared to be blocking the GUI thread). So, I had it implement Runnable, made a run method that just waits for the thread to be stopped:
    while (StopTheThread == false)
    try
    Thread.sleep(10);
    catch (InterruptedException e)
    //System.out.println("here");
    (the thread is started in the class constructor)
    I assumed that the other methods in this class would be running in the thread and would thus not block when called, but it appears the SWT GUI thread is still blocked. Is my assumption wrong?

    powerdroid wrote:
    Oh, excellent. Thank you for this explanation. So, if the run method calls any other method in the class, those are run in the new thread, but any time a method is called from another class, it runs on the calling class' thread. Correct?Yes.
    This will work fine, in that I can have the run method do all the necessary calling of the other methods, but how can I get return values back to the original (to know the results of the process run in the new thread)?Easy: use higher-level classes than thread. Specifically those found in java.util.concurrent:
    public class MyCallable implements Callable<Foo> {
      public Foo call() {
        return SomeClass.doExpensiveCalculation();
    ExecutorService executor = Executors.newFixedThreadPool();
    Future<Foo> future = executor.submit(new MyCallable());
    // do some other stuff
    Foo result = future.get(); // get will wait until MyCallable is finished or return the value immediately when it is already done.

  • Thread question - unknown method exception!?!

    I am using the following code:
    public void killAnimal(Animal a) //Animal extend Thread
    a.stop();
    a.destroy(); //unknown method exception at this line!
    Basically a thread sends another thread into this method (to kill the Animal/thread when it eats it), but i get an unknown method expection and both threads stop updating
    Any advice

    i have recompiled it. And .destroy() is a built
    method within Thread class is it not?
    And my class EXTENDS Thread so it automaticaly has
    s access to the methods present in the Thread class
    right?. And the fact it compiles and runs means the
    method is detected. Its only when it gets to that
    point that it outputs the exception.Yes but that really wasn't clear from your post. And the name of the class("Animal") is misleading as well.
    The Thread.destroy() method specifically throws the NoSuchMethodError.
    It probably does that because there is no other appropriate unchecked error, although UnsupportedOperationException might be more appropriate.
    >
    Do i need to use .destroy()? Would using .stop() be
    efficient enough? or would that thread still be
    suckin up memory and other system resources?Until the run() method exits the thread exists. How you stop it other than that does not have any impact.

  • Nio Question - get() method in ByteBuffer

    I m working on the telnet client program, in the negotiation phase of telnet
    connection, my telnet server returns me FF FB 03 FF FB 01 (WILL SUPPRESS-GO-AHEAD
    WILL ECHO), I read those bytes into a ByteBuffer, and trying to print them out
    to the screen.
    static ByteBuffer bb = ByteBuffer.allocateDirect(1024);
    public static void main(String args[]) throws IOException{
    InetSocketAddress isa = new InetSocketAddress("192.168.1.1", 23);
    SocketChannel sc = null;
    try {
    sc = SocketChannel.open();
    sc.connect(isa);
    bb.clear();
    sc.read(bb);
    bb.flip();
    System.out.println(bb.get());
    For byte FF FB 03 FF FB 01, I got result like -1 -5 3 -1 -5 1
    it seems to me that "print" can't print byte to screen, I therefore tried
    this "new Byte(bb.get()).intValue()", however it gives me the same result
    03 01 are properly displayed, does it mean java interprets 1111 1111 as negative?
    how do I display them as integer value?

    Integer.toHexString(int) will return a string containing the hexadecimal representation of the value of the int.

Maybe you are looking for

  • Using an exteral hard drive to edit movies

    Hello, I need some help. I have a iBook G4 and am running OS X 10.3.9. I have a lot of footage that I want to import and edit in imovie. I do not have enough hard drive space on my laptop to do that. I would like to buy and external hard drive to edi

  • Grid computing in oracle 10g

    Hello Everybody :) I want to make an application which will be added to grid computation (it will be inverting a matrix with dimension 1000x1000 in loop with lenght of 999999 ). I have got few questions. 1 How to make grid?? I' ve used Oracle 10gXE f

  • MM06E003 Number range and document number

    hi Is the functionality of MM06E003 Number range and document number( user exit ) is same in ECC 6.0  and ECC 5.0 Regards, vijay

  • Use of af:panelCollection with Master Detail

    Hi, I am using Master Detail Top Bottom Template. Also for these tables I wanted to use af:panelCollection. But when I add an af:panelCollection to my table ( Master Table), Master Detail functionality of these tables go away. As in on clicking on an

  • CF Builder 3 and document root of the server

    I'm trying to test CF Builder 3 before deploying it to user machines so I can help them with the initial setup.  However I'm confused by the process of linking code to the built in CF Express and the online help files are either lacking what I need t