Utility method

I know PreparedStatements help prevent SQL injection and ticks.
The only thing I notice is it doesnt handle greater than and less than such as < with a > entry in a form. When they are entered into a form that populates oracle it seems to disappear when I view the record on a web page.
I can create a Utility method to handle this and was wondering if this is what others do to handle < with a > form entries?

Escape it into an HTML entity when displayed.

Similar Messages

  • [svn:fx-3.x] 7499: Addendum to fix for BLZ-233 - adjust visibility of new internal heartbeat util methods to protected from private .

    Revision: 7499
    Author:   [email protected]
    Date:     2009-06-02 16:10:08 -0700 (Tue, 02 Jun 2009)
    Log Message:
    Addendum to fix for BLZ-233 - adjust visibility of new internal heartbeat util methods to protected from private.
    QA: No
    Doc: No
    Checkintests Pass: Yes
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-233
    Modified Paths:
        flex/sdk/branches/3.x/frameworks/projects/rpc/src/mx/messaging/ChannelSet.as

    inspired2apathy wrote:
    ... The goal is a ScrollPane that automatically wraps the text inside it. I've just about got it, but I have one thing that's not working. If I just put the JTextArea{s} in as the Editor, then you lose the any text that doesn't fit inside whatever the initial size was. Instead, I put the JTextAreas inside a JScrollPane which works fine, except that I still have to determine the size of the JScrollPane in advance. I would like to make each Editor/JScrollPane start out with just a single line of text and expand until it reaches a certain small number of lines.
    ... What am I missing?THE BASICS. See if this isn't what you are trying to do.
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class Test
      public static void main(String[] args) {
        JTextArea ta = new JTextArea();
        ta.setLineWrap(true);
        ta.setWrapStyleWord(true);
        JScrollPane sp = new JScrollPane(ta);
        JFrame f = new JFrame();
        f.getContentPane().add(sp, "Center");
        f.setBounds(0, 0, 400, 300);
        f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
        f.setVisible(true); 
    }OP, your code was too long and complicated for me to compile and run. However, aren't you forgetting the two simple methods <tt>JTextArea.setLineWrap()</tt> and <tt>JTextArea.setWrapStyleWord()</tt>? Furthermore, I absolutely see no need for you to extend SWING components for demonstration this simple -- that is, if I understand your problem correctly.

  • How to use utility methods to implement synchronization ?

    Hi,
    We know that Vector is synchronized , but as it causes performance loss . So how can I use the utility methods of Collections to implement synchonization.
    Please help me.
    Thanx in advance.

    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#synchronizedCollection(java.util.Collection)
    See also
    http://java.sun.com/j2se/1.5.0/docs/guide/collections/index.html
    http://java.sun.com/j2se/1.5.0/docs/guide/collections/overview.html
    http://java.sun.com/docs/books/tutorial/collections/index.html
    http://java.sun.com/docs/books/tutorial/collections/implementations/wrapper.html

  • How to encrypt a big folder without using disk utility method ?

    How to encrypt  big folder
    suck as 100 GB
    without using disk utility method ??

    Click the partioned disk > Hit Erase Tab  >
    Under "Format" Select "MAC OS Extended Journaled, Encrypted
    Click "Erase"
    Set Password ..
    Done

  • Safe Casting Collections using utility methods

    Hi,
    I am wondering, are there any utility methods that help extract the elements form one collection<?> to Collection<Box>??
    for example, I may have a method signiture that takes List<Box> as a parameter called doYourJob.
    and I have a List of List< ? extends Object> someList.
    ofcourse I cant use this object for that method:
    List<? extends Object> someList;
    doYourJob(someList);//wrong
    public void doYourJob(List<Box>list){
    }what I need to do is to make a utility method that extracts a spisific type from the collection and puts them in another collection:
    public List<Box> extract (List<?>list){
    ArrayList<Object>newList=new ArrayList<Object>();
    for(Object o:list){
    if(o instanceof Box)newList.add((Box)o);
    return newList;
    }my question is: are there in the jave API utility methods to change the generic type of a collection by changing the collection as whole.
    Maybe I can send the type that I want as Box.class and it returns that list.
    Sorry if the question is repetitive!

    I wish his was something that was easier to do in
    Java because I think more people would use that
    approach if it weren't so verbose.
    Maybe I'm confused here, but I don't think of coding
    up an interface as being an especially verbose or
    arduous exercise...? But then I'm not too sure what
    you're comparing it with.It's not writing the interface that's the problem. It's writing the code to wrap the existing classes in your wrappers or whatever implementation you come up with. Doing it once is no big deal but if you are using it as a fairly common approach in your code (as I do) it can become pretty messy. What really bothers me is that it takes a lot of fluff code. I've been looking at other languages esp. Scala on this and they have very concise composition syntax. I'm not ready to go with Scala but I think if the language steered people more towards composition and 'recasting' objects through interfaces, people would do more of it.
    I'm working with one now that's all about return
    codes and simulating in-out parameters (I said it
    once and I'll say it again: Joel Spolsky is an
    idiot.)
    Hmm. I read Joel On Software, and from a business
    perspective he seems pretty clued in. I've never
    encountered any of his code, nor read anything much
    of a purely technical-diatribe nature from him. But
    I'm still alittle surprised.Not sure if you've read this:
    http://www.joelonsoftware.com/items/2003/10/13.html
    I'm exaggerating, of course. I don't really think he's an idiot but I think the above is super-extra-double-plus stupid. I really can't fathom why he thinks return codes are superior. I can only think he doesn't really get how exceptions work.
    There's also this ironically named URL:
    http://www.joelonsoftware.com/articles/Wrong.html

  • Tool/Utility/Method to retrieve roles and mapping of those roles.

    Hi friends,
    We are running SAP EP6 SP2 on WEB AS 6.20.
    I want name and description of all roles created and mapping of those roles ( Roles -> groups and Roles -> Users ) in this system. The one way to do it is using User Administration -> Roles but it'll take a lot of time. Is there any tool/utility/shortcut method available for the same?
    Regards,
    Nilz
    Message was edited by: nilz

    Hi nilz,
      I don't think there is any tool as such to do this. U need some programmatic approach for this. U can get the roles using pcd search but I am not sure if u can get the mapping details.
    Regards,
    Harini S
    [ <b>Don't forget to reward points for helpful answers</b> ]

  • To access context values in java util methods in webdynpro java

    My requirement is to access the wdcontext values in the my util classes.
    kindly  suggest how to access the context value in my util class
    Regards
    Priya

    The context reference must be passed to the .java class in order to access same in the .java
    for example,
    Change MyUtil.java - get the reference to this file.
    public class MyUtil {
    //make a local variable of context element type.
    private IPrivateCompView.IHashContextElement local_context;
    //add context type in Constructor
    public MyUtil (IPrivateCompView.IHashContextElement local_context, /*rest of params*/){
            this.local_context = local_context;
            //.... rest of initialization
    In Webdynpro, initialize the call by passing the context reference.
    IPrivateCompView.IHashContextElement hashmap = wdContext.currentHashContextElement();
    //initialize my class
    new MyUtil( hashmap, /*rest of params*/);
    regards,
    Nikhil

  • Generically calling a method on an object

    Hello,
    I am trying to write a small utility method to generically call a method on an object.
    This is what I have.
        public static void doCall(Object o, String methodName, Object ... args){
            Class[] types = new Class[args.length];
            int i = 0;
            for(Object arg : args){
                types[i] = arg.getClass();
            try {
                Method m = o.getClass().getMethod(methodName, types);
                m.invoke(o, args);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("Error dynamically calling method " + methodName + " on " + o.toString());
        }It doesn't work because it can't find the method. If I hard code the parameter types as "new Object[] {Double.TYPE}" it works fine (on methods that take a double).
    So, my question is, how can I generically set up the parameter types based on the types of the arguments?
    Thanks,
    ~Eric

    The problem is not on calling agr.getClass(), your primitive double is already autoboxed to a Double object. It is the doCall(...) method who expects an object, not a primitive. So when giving it a primitive value, java autoboxes it to the corresponding object type.
    This means your attempt will only work if the methods to call do not have any primitives as parameters.
    Test this code:
    public class GenericMethodCaller {
         public static void doCall(Object o, String methodName, Object ... args){
            Class[] types = new Class[args.length];
            int i = 0;
            for(Object arg : args){
                types[i++] = arg.getClass();
            try {
                Method m = o.getClass().getMethod(methodName, types);
                m.invoke(o, args);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("Error dynamically calling method " + methodName + " on " + o.toString());
         public static void main(String[] args) {
              Callable callee = new Callable();
              callee.callabelMethod(10d);          
              GenericMethodCaller.doCall( callee, "callabelMethod", 10d ); // 10d gets autoboxed to a Double object.
    class Callable {
         public void callabelMethod(Double o) {
              System.out.println("callabelMethod(Double o) called");
         public void callabelMethod(double o) {
              System.out.println("callabelMethod(double o) called");
    }The output will be:
    callabelMethod(double o) called
    callabelMethod(Double o) called
    - Roy

  • Unable to capture messages from java.util.logging

    I have a class called (Caller.java) which invokes a method called foo from another java class(Util.java) using reflection API.Now this method foo logs messages using Java's logger.My requirement is to call foo for 3 times from Caller and capture/redirect the log messages into 3 log files.
    But only the first log file is capturing the log messages(from logger) and other two are not ?
    Plz suggest if I am doing somethin wrong here ?
    Caller.java
    package project2;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.PrintStream;
    import java.lang.reflect.Method;
    public class Caller {
        public Caller() {
        public static void main(String[] args) throws Exception {
            Caller caller = new Caller();
            for (int i = 0 ;i<3 ;i++ )  {
                caller.createLogStream(i);
                System.setOut(caller.getPs());
                System.setErr(caller.getPs());
                /*****************Invoking Util.java*****************************/
                Class clas = Class.forName("project2.Util");
                Method m = clas.getMethod("foo",null);
                Object obj =clas.newInstance();
                m.invoke(obj,null);
        public void createLogStream(int i) throws FileNotFoundException {
            ps = new PrintStream(new File(System.getenv("HOME")+File.separator+"MyLog"+i+".log"));
        public void closeLogStream(){
            ps.close();
            ps = null;
        private PrintStream ps = null;
        public PrintStream getPs() {
            return ps;
    } Util.java
    package project2;
    import java.util.logging.Logger;
    public class Util {
        Logger logger = null;
        public Util() {
            logger = Logger.getLogger(this.getClass().getName());
        public void foo(){
            System.out.println("Hello out stream");
            System.err.println("Hello error stream");
            logger.info("This is an information");
            logger.warning("This is a warning message");
            logger.severe("This is fatal!! ");
    }First Log file MyLog0.log:
    Hello out stream
    Hello error stream
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!!
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!!
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!! Other 2 log files have only this much
    Hello out stream
    Hello error stream

    A stale Connection Factory or Connection Handle may be used in SOA 11g
    Regards,
    Anuj

  • Closing an anonymous stream in method call

    Will an anonymous stream in a method call be closed in the same manner an anonymous stream that is created in an object instantiation will be?
    I know this will close the anonymous FileInputStream:
    DataInputStream in =
    new DataInputStream(new FileInputStream("filename.txt"));
    /* ... code ... */
    in.close();But will this?
    MyPropertiesClass myPropertiesClass = new MyPropertiesClass();
    myPropertiesClass.store(new FileOutputStream("file.txt"));MyPropertiesClass extends Properties, and uses its store().
    I know the JavaDoc for Properties says:
    "After the entries have been written, the output stream is flushed. The output stream remains open after this method returns."
    My question is will the FileOutputStream("file.txt") be closed and garbage collected eventually after this method call because I don't have a reference to it? myPropertiesClass sticks around for a long time afterwards, will the FileOutputStream as well?
    Thanks for any insight,
    KJ

    My question is will the FileOutputStream("file.txt") be closed and garbage collected eventually after this method call because I don't have a reference to it? > myPropertiesClass sticks around for a long time afterwards, will the FileOutputStream as well?Your only hope would be if FileOutputStream overrode finalize and closed the stream there -- but it doesn't (check the API -- finalize isn't overridden). I doubt if Properties retains a reference to the OutputStream you pass to store -- why would it need to? In any case, the bottom line is that output stream isn't being closed until your process exits.
    Why not bite the bullet and rewrite that line of code so that you can explicitly close the stream?
    OutputStream out = new FileOutputStream("file.txt");
    try {
        myPropertiesClass.store(out);
    } finally {
        out.close();
    }It's not one line, but who cares? You could wrap it up in a short utility method:
    static void storeProperties(Properties properties, String path) {...}

  • Purpose of declaring the method or class or static and as instance

    what is the purpose of declaring a method in a class or the class itself as static.
    Does it mean we cannot create a copy of that class or method if we declare it as static.
    if so then why do they dont want that class to be created as a copy ?
    Why do they want to declare a class as static
    please provide some conceptual undersatnding regarding the static and instance class with one example

    Static methods are often used for the implementation of utility methods. Please have a look at the class CL_ABAP_CHAR_UTILITIES for example.
    You use the methods of this class in the same way as you would use a function in ABAP (like
    LINES( itab )
    ). You use it in a static way because the functionality is always the same no matter in what context you are calling the function.
    The purpose of instance methods is that their logic is in some way related to an attribute of the object instance that you use to call it.
    For example, you create an instance of object PO (a purchase order) called MY_PO. Then the method
    MY_PO->ADD_POSITION
    would add a position to a concrete PO that has a unique number etc. But if the object has a static method DELETE_POSITION then it just deletes the current position of a PO, regardless on which concrete PO you are acting at the moment.
    I hope this clarifies it for you.
    Regards,
    Mark

  • How to Call  a Class method in another class.

    Hi All,
    I have created two class
    The class JavaAgent create a object of another TestFrame1 class . I am trying to call
    out.setSize(200,100);
    out.setVisible( true );
    above two method.
    I am a doing some thing wrong. I am getting the error " symbol cannot be resolved".
    public class JavaAgent extends AgentBase {
    private TestFrame1 out;
    private Session session;
    private Database db;
    private Frame frame;
         public void NotesMain() {
              try {
                   Session session = getSession();
                   AgentContext agentContext = session.getAgentContext();
    Database db = agentContext.getCurrentDatabase();
    String title = db.getTitle();
    // System.out.println ("Current database is \"" + title + "\"");
                   TestFrame1 out = new TestFrame1( );
    out.setSize(200,100);
    out.setVisible( true );
    Thread.sleep(250);
              } catch(Exception e) {
                   e.printStackTrace();
    import lotus.domino.*;
    import java.awt.*;
    import javax.swing.*;
    class TestFrame1
    private Session session;
    private Database db;
    TestFrame1( )// Constructor
    JFrame frame = new JFrame("Test Frame 1");
    }

    Hi,
    I guess you are not able to invoke setSize and setVisible method. Am i right ??
    First make sure your TestFrame class is compiled.
    The setSize() and SetVisible are defined in Component and inherited by JFrame.
    In order to use these methods you have to make your TestFrame as subclass of JFrame or provide a utility method
    and from there explicitly call these methods by using the associated JFrame reference.
    And in your JavaAgent class why you declared TestFrame1 twice?? it's really hard to predict your intention.
    Anyway i hope this code will helps you bit...
    import javax.swing.JFrame;
    public class JavaAgent{
         JavaAgent()
          * @param args
         public static void main(String[] args) {          
              TestFrame1 test = new TestFrame1("Test Frame1");
              test.setSize(250,250);
              test.setVisible(true);
    class TestFrame1 extends JFrame
         TestFrame1(String title)
              super(title);

  • Java.lang.NoSuchMethodException Using Method.invoke(...)

    I try to use Method.invoke() to invoke a method from a class. The method
    has parameters with type JTextArea and JMyFrame, but I got the error
    messages java.lang.NoSuchMethodException . Any ideas???
    If I remove parameter "JFrame mainFrame" in start() method and it is working fine. Not sure why JMyFrame will throw this exception, as JMyFrame is derived from JFrame class
    public class MyFrame extends JFrame
         try
    ClassLoader loader
    = new MyClassLoader(Integer.parseInt("3"));
    Class c = loader.loadClass("NewMenuPackage.NewMenu");
    Class[] params = { JTextArea.class, JMyFrame.class };
         Method m = c.getMethod("start", params);
         Object obj = c.newInstance();
    m.invoke(obj,
         new Object[] {
              textArea,
              JMyFrame.this
    catch (Throwable e)
    JOptionPane.showMessageDialog(this, e);
    package NewMenuPackage;
    import javax.swing.*;
    public class NewMenu
         private static JMenuItem menuItem = new JMenuItem("New Menu");
         public static JMenuItem getJMenuItem()
              return menuItem;
         public static void start(JTextArea textArea, JFrame mainFrame)
              System.out.println("NewMenu->start()...");
    }

    Your "params" Class array has to specify the exact classes of the method, not subclasses. The line that is causing the NoSuchObjectException to be thrown is "c.getMethod("start", params);".
    You have to write your own reflection utility methods to find a method that matches on parameter subclasses.

  • What is the best method for updating Bios for 8.1 on GT70 2OD

    Hey,
    I've been getting a bunch of different BSODs and its been recommended I update my bios because I am running win 8.1
    Im just a little confused with which method would be best to update the bios. The EFI bios utility method on the PDF looks easy enough, but the information above that says to use the flash utility in the compressed file. Is that the afuwinx64.exe file and I run it from windows? or can I do something with the .bat files?
    As you can tell I dont know to much about this kind of thing, I have been avoiding this update hoping to solve all issues without it, no such luck unfortunately. The feedback I got said that it seems as If something is misconfigured. in your opinion is it likely not having the bios updated could cause issues?
    Thanks.

    Use one of the methods outlined in the PDF files on the website from MSI. Either of those methods should work just fine.
    The generally recommended method though is using the BIOS HQ Flasher.
    >>Use the MSI HQ Forum USB flasher<<
    I would NOT just flash using the exe or the bat files, as this can cause issues if done improperly.
    I believe there was a bios update for the GE series of laptops because of a configuration issue for Windows 8.1. I don't believe the update for the GT series for Windows 8.1 had that same issue.

  • Advantages and disadvanteges with static methods

    Hi,
    Can anybody suggest me the advantages and disadvantages of static methods? In my project i am using templates which are used by different programs and in that templates i am using static methods.
    It is web application. is there any problems if made methods as static in templates that are used by diferent clients?
    Thanks
    Karimulla

    A static method can't be overridden, and static methods are usually only used for some utility methods and other things which don't belong to the class. I would probably not make the methods static.
    Kaj

Maybe you are looking for

  • Site-to-ste VPN with overlapped subnet.

    Hi Friends I have to set up site to site VPN with overlapped network ASA 5540 and checkpoint   what is the best parctice to achive tis goal Thanks in advance

  • Rendering problem in cs6

    A particular project I am working on will not render in cs6.  Every time i try to render the timeline it freezes about 1/3 of the way through.  I can render one clip at a time for a few clips but then it consistently freezes after about 3 renders and

  • When installing Adobe Captivate I get msg: unable to set-up control panel

    When installing Adobe Captivate I get msg: unable to set-up control panel..Does anyone know how to resolve?

  • 10.5.6 beware

    The Mac, god bless it, is so reliable, so dependable it's very easy to take its stability for granted. So if you use a Mac, or know anyone who does, it would be a good idea to forward this message on to them. For me downloading and installing Apple's

  • Maximun limit of rows - exported to excel

    Hi All, i am using Oracle Business Intelligence Discoverer Desktop version 10.1.2.00.00 the maximum number of rows that i can export to excel is 65,536. i have tried exporting in excel 2003 and 2007 P.S un-ticked the Tools > Options > Query Governor