Can I put a class into a jsp??

I want to put this class into a jsp.. and reference it when I need it... can i just dumped it into a jsp... or do I have to do anything specific to it...
public class areaformat {
     public synchronized static String replace(String str, char oldchar, String newstr)     {
          StringBuffer sb = new StringBuffer(str);
          int len = sb.length();
          try     {
               for (int i=0; i<=len; i++)     {
                    if (sb.charAt(i) == oldchar)     {
                         sb = sb.replace(i, i, newstr);
                         sb.deleteCharAt(i + newstr.length());
                         i = i + newstr.length() - 1;
          }catch(StringIndexOutOfBoundsException sioobe)     {
               if (len == 1 && str.equals("'")) {
                    sb = new StringBuffer(newstr);
          return sb.toString();
Thx RIch

No, you can't. You can put only the function in the beginning of your jsp file like:
<%!
public void myFunction(...){
%>
So, you can use myFunction wherever you want in the page.
The other method is to compile your class in a file called "javac className.java" and the put the .class file generated in your WEB-INF/classes folder of your web-container.

Similar Messages

  • How can i put one scene into JPanel of the swing?

    how can i put one scene into JPanel of the swing?

    980571 wrote:
    ty for the information but i have a problen with JFXpanel when i try to into a panel it doesnt display insideSorry to hear that. If you want assistance with the code, feel free to post the relevant parts of it. Make sure to use \ tags when you do.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can I put my bookmarks into the sequence I want, alphabetical or otherwise?

    How can I put my bookmarks into the sequence I want, alphabetical or otherwise?

    http://kb.mozillazine.org/Sorting_bookmarks_alphabetically <br />
    http://kb.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox

  • Can i put photos back into the camera chip once they have been imported into my mac?

    Can i put photos back into the camera chip once they have been imported to my Mac?

    Export them
    File -> Export
    to a folder on the desktop. From there copy them back to your camera.
    Remember, the camera has a quite specific set up of folders, and you'll need to put the files back in the correct place for them to be viewable on the camera.
    This User Tip
    https://discussions.apple.com/docs/DOC-4921
    has details of the options in the Export dialogue.

  • How can i put below  table into internalt table

    how can i put below  table into internalt table and want to add both internal table into 3rd internal table.
    SELECT  * FROM J_1IEXCHDR  WHERE STATUS = 'P'.
    WRITE: / J_1IEXCHDR-LIFNR,
              J_1IEXCHDR-DOCNO,
              J_1IEXCHDR-EXYEAR,
              J_1IEXCHDR-BUDAT.
    SELECT * FROM J_1IEXCDTL  WHERE TRNTYP = J_1IEXCHDR-TRNTYP
                              AND DOCYR  = J_1IEXCHDR-DOCYR
                              AND DOCNO  = J_1IEXCHDR-DOCNO.
       WRITE: / J_1IEXCDTL-EXBAS,
                J_1IEXCDTL-EXBED,
                J_1IEXCDTL-RDOC1,
                J_1IEXCDTL-ECS.
    ENDSELECT.
    ENDSELECT.
    please help
    thanks in adavaced.

    hi laxman,
    use for all entries and get the required data.
    SELECT * FROM J_1IEXCHDR into table itab1 WHERE STATUS = 'P'.
    if not itab1[] is initial.
    SELECT * FROM J_1IEXCDTL into table itab2 for all entries in itab1 WHERE TRNTYP = itab1-TRNTYP
    AND DOCYR = itab1-DOCYR
    AND DOCNO = itab1-DOCNO.
    endif.
    so itab2 will have the common records...This will solve ur problem..
    also u can do other method declare an final internal table with the common fields of the two internal table.
    then after getting data in itab1 and itab2.
    loop at itab1.
    move-corresponding itab1 to itab3.
    read table itab2 with key <give the fields> = ......
    if sy-subrc eq 0.
    move-corresponding itab2 to itab3.
    endif.
    append itab3.
    endloop.
    Regards,
    nagaraj

  • Can't put the computer into sleep if VPN is connected

    I think I have found a win7 bug. The problem is that I can't put my computer into sleep if VPN is connected. The VPN client I used is Microsoft VPN client. The VPN works fine.  But if I click sleep button with VPN connected, the computer screen turns
    black, the fan speeds up, and the signal light tells me the computer is  still on, not in sleep mode. When I try to wake up my computer by tapping the enter key, space, or moving the mouse, it just doesn't work at all: the fan speeds faster and faster
    and the computer heats up. The only thing I can do now to save my computer from darkness is to hit and hold the power button, powering off the computer. The sleep function works just fine if the VPN is disconnected. I can easily wake my computer up by tapping
    the enter key. I don't know whether this problem is only present on my computer or universally present on all win7 computers.
    The following is my system info:
    OS Name Microsoft Windows 7 Ultimate
    Version 6.1.7601 Service Pack 1 Build 7601
    OS Manufacturer Microsoft Corporation
    System Manufacturer LENOVO
    System Model IdeaPad Y460
    System Type X86-based PC
    Processor Intel(R) Core(TM) i5 CPU       M 460  @ 2.53GHz, 2534 Mhz, 2 Core(s), 4 Logical Processor(s)

    Hi,
    Please collect the report for the further troubleshooting. Note:Please do the following steps when VPN is connected.
    1. Click Start, type in “cmd”, right click it and choose “Run as administrator”.
    2. Type in the following command.
    Powercfg –energy
    3. Find the report file in the location showed in Command window.
    4.
    Upload it.
    Kim Zhou
    TechNet Community Support

  • I can't put more music into my iPod touch 4gen

    i can't put more music into my iPod touch 4gen

    Do you have a question?
    Why can't you pur more music on the ipod?
    Perhaps if you were to explain you issue, then someone could help.

  • Can we type cast class into interface?

    Hello all,
    Can we type cast class into interface?
    If it can ,pls explain me in which suituation can we do?

    You don't need to explicitly typecast a class to an interface, if the class is implementing the interface.
    Example: List list = new ArrayList();    // Cast not required.And search on Google first. I'm sure this question would be answered by the lamest of tutorials.

  • Importing classes into a jsp

    I have created a class file called BindListener.java and put it in my root directory in my web module. I cannot however get the import statement for the jsp right, my root directory is called JBuilder. I have tried putting it in the WEB-INF classes folder also but still when I try to execute thr jsp it dosent work.
    There is no package declared in the classs file and it does not extend any other class, however it implements the HttpSessionBindingListener interface.
    I can call servlets from my JSP in the WEB-INF classes dir using /JBuilder/ServletName
    I am mondo confused please help

    I have created a class file called BindListener.java
    and put it in my root directory in my web module. I
    cannot however get the import statement for the jsp
    right, my root directory is called JBuilder. I have
    tried putting it in the WEB-INF classes folder also
    but still when I try to execute thr jsp it dosent
    work.
    There is no package declared in the classs file and
    it does not extend any other class, however it
    implements the HttpSessionBindingListener interface.You have to put the class in a package, then put the .class file in a package directory under WEB-INF/classes. So for example:
    package beans;
    public class BindListener ...
    //goes into this directory structure
    <APP_ROOT>/
      *.jsp
      WEB-INF/
        web.xml
        classes/
          beans/
            BindListener.class
    //And is imported into your JSP using one of the following
    // -- EITHER --
    <%@ page import="beans.BindListener" %>
    <%
      BindListener bl = new BindListener();
    %>
    // -- OR --
    <jsp:useBean id="bl" class="beans.BindingListener"/>>
    I can call servlets from my JSP in the WEB-INF
    classes dir using /JBuilder/ServletName
    I am mondo confused please help

  • How can I split a class into 2 files?

    I converted a C++ program to Java recently and it works fine, but I ran into a problem.
    One file is very large and I need to add more functionality. Unlike with C++ where you can just put new functions in another file, I don't see a way to do it in Java.
    I made another file, and therefore another class, but the compiler complains that it can't call a static function from non-static context. (I did not declare it static so I guess it's assuming it) But I understand why. So I made the new class "extend" the old one so "this" would exist but that doesn't work -- Is it because the new class is a subclass of the original class?
    There must be a way to do this. But I don't see what is likely obvious. HELP! And thanks.

    JavaIsBetterThanCPP wrote:
    There must be a way to do this. But I don't see what is likely obvious. HELP! And thanks.Unfortunately Java has no concept of "partial classes" like C# has. Generally, however, a class that is large enough to split up into separate files is either one class that should be modularized further into separate classes, or it already is modularized and all that code is the result of many inner classes. What some people do is promote those inner classes to top-level members in their own file, and mark them as package-private. Using a package you can basically have two classes that know everything about each other and have full access to each other.
    But personally, and until I see justification otherwise, semantics in Java being unbreakingly tied to a certain file structure and naming is the most bonehead and, frankly, non-Java thing about Java.
    There's probably a pre-processor out there that will let you split a class into multiple files and will combine them into a single source file just-in-time to pass to the compiler.

  • How can i put a file into blob(using sun.jdbc.odbc.JdbcOdbcDriver)

    Hi
    i tried to put a file into blob , but got a problem.....
    My environment:windows 2000pro,JBuilder 5.0 enterprise,oracle 8.1.6,(not install oracle jdbc driver )
    a part of program(my program is very uglily,if anyone want,later i paste it ba....~_~)
    //Statement stmt2=null;
    //Resultset rs2;
    //opa1 is the blob data
    void saveBlobTableToDisk(Connection con) {
    try {
    stmt2=con.createStatement();
    sqlStr2="SELECT * FROM emp3 where id=1004";
    rs2=stmt2.executeQuery(sqlStr2);
    while (rs2.next()) {
    Blob aBlob=rs2.getBlob("opa1");
    i got the exception :
    " null
    java.lang.UnsupportedOperationException
         at sun.jdbc.odbc.JdbcOdbcResultSet.getBlob(JdbcOdbcResultSet.java:4174)
         at test3.Frame1.saveBlobTableToDisk(Frame1.java:48)
         at test3.Frame1.<init>(Frame1.java:26)
         at test3.Application1.<init>(Application1.java:5)
         at test3.Application1.main(Application1.java:8) "
    and the windows pop up a messagebox said that(about) my memory "0x09af007f" could not read, error in javaw.exe .
    Later i used (ResultSet)getBinaryStream() to solve it. but getBinaryStream() only return a InputStream,so that i can make blob to a file,but i can't make a file to blob using jdbc.....
    I am very stupid that installing sun java, oracle jdbc driver etc....(because i must set a lot of thing such as classpath,java_home etc), Can i only use JBuilder to do that ?
    Or i must install oracle jdbc driver ?
    Thanks.

    My guess here is that Sun's JDBC-ODBC bridge doesn't handle the BLOB datatype. Most ODBC drivers don't support that datatype, so I wouldn't expect the bridge to.
    Is there a reason that you can't use the Oracle driver?
    Justin

  • How can i put a file into blob using jdbc !?

    Hi
    i tried to put a file into blob , but got a problem.....
    My environment:windows 2000pro,JBuilder 5.0 enterprise,oracle 8.1.6,(not install oracle jdbc driver )
    a part of program(my program is very uglily,if anyone want,later i paste it ba....~_~)
    //Statement stmt2=null;
    //Resultset rs2;
    //opa1 is the blob data
    void saveBlobTableToDisk(Connection con) {
    try {
    stmt2=con.createStatement();
    sqlStr2="SELECT * FROM emp3 where id=1004";
    rs2=stmt2.executeQuery(sqlStr2);
    while (rs2.next()) {
    Blob aBlob=rs2.getBlob("opa1");
    i got the exception :
    " null
    java.lang.UnsupportedOperationException
         at sun.jdbc.odbc.JdbcOdbcResultSet.getBlob(JdbcOdbcResultSet.java:4174)
         at test3.Frame1.saveBlobTableToDisk(Frame1.java:48)
         at test3.Frame1.<init>(Frame1.java:26)
         at test3.Application1.<init>(Application1.java:5)
         at test3.Application1.main(Application1.java:8) "
    and the windows pop up a messagebox said that(about) my memory "0x09af007f" could not read, error in javaw.exe .
    Later i used (ResultSet)getBinaryStream() to solve it. but getBinaryStream() only return a InputStream,so that i can make blob to a file,but i can't make a file to blob using jdbc.....
    I am very stupid that installing sun java, oracle jdbc driver etc....(because i must set a lot of thing such as classpath,java_home etc), Can i only use JBuilder to do that ?
    Or i must install oracle jdbc driver ?
    Thanks.
    D.T.

    My guess here is that Sun's JDBC-ODBC bridge doesn't handle the BLOB datatype. Most ODBC drivers don't support that datatype, so I wouldn't expect the bridge to.
    Is there a reason that you can't use the Oracle driver?
    Justin

  • Importing Custom Classes into a JSP page

    Hello,
    I have created custom package com.srjgroup.report. It sits in C:\workspace\src\com\srjgroup\report directory. I have java files as well as compiled classes there. No jar files there.
    did amend classpath to point to this directory.
    In my JSP page I have the import statement as following
    import="java.sql.*, java.util.*, java.text.SimpleDateFormat, com.srjgroup.report.*"It imports all the packages without any errors. However, when I try to use one of the classes in the package, I get error
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 3 in the jsp file: /SQLServer.jsp
    Generated servlet error:
    SRJReports cannot be resolved to a type
    SRJReports is one of the classes that I am trying to use in that package. When I comment out all references to the class, everything is fine.
    So, to fix this I moved the entire package to
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\lib direcory, preserving the hierarhy. So, now my custom package is located here:
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\lib\com\srjgroup\report again there are no jar files, only java and classes here. Still, no go.
    What am I doing wrong ?

    Put the class in
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes\com\srjgroup\report
    One more thing, there is no subdirectory in lib directory. You may look at the example within tomcat for reference. I start from there.

  • How can I put my system into StandBy Mode?

    Hi
    I am not able to put my system into stanby mode.
    How can I do that?

    Hi
    As Ivan said you can use these two options.
    Furthermore I would recommend checking the settings in the Toshiba power saver (if is installed)
    Possibly you have to activate this option before using.

  • How can I put the signature into the data file.

    Hi all,
    I want to put the signature into the data file, mean the data file will be on the top and the signature will be at the buttom.how can i do that?
    Thanks.
    example:-
    dataFile.txt
    Name=...
    Address=...
    Signature=6A07C70E....123FEAB(Hex)

    Thanks for your reply.
    First, i have a keypair (public key and private key).
    I use the private key to initialize the Signature and
    use the Signature to sign a data file ( dataFile.txt) .
    So when i need to comfirm the data file not being modify
    I have to verify the data file with the Signature and the public key.
    I hardcoded the public key in my program so my client (receiver of data)
    need only the Signature file and the data file (2 files).
    So how can i combine the Signature file and the data file into 1 file?

Maybe you are looking for

  • Questions on my dock bar

    On several of my program icons like microsoft powerpoint and entourage there is a question mark that appears when I click on it, I can't do anything with the application because that is all that happens.  It also happens on a open file from micosoft

  • Adobe Illustrator CC crashes on Mac OS X 10.9

    It crashes when it starts, no error messages, just crash... But it works fine with root account. What's the problem?

  • Help it's frozen, now it wont turn back on

    My I pod is frozen, I've tried to reset it and it just goes blank and the only way to turn it back on is to switch it to hold, then back off hold and it's stil frozen. And it turns off all the time. I just got this thing and I'm not liking it so far,

  • Exporting Playlists hangs or crashes/freezes iTunes

    This just started happening today. I haven't installed of chnaged any hardware or sofrware. Basically, I right click > Export Playlist and it will either hang before eventually saving or completely freeze/crash iTunes. The larger the playlsit, the lo

  • INterface not viisble in sxi_monitor

    Hello Everyone, I have created a  JDBC to IDOC scenario. .. All the configurations are made and i tested the xi objects  as well.. I could see that in QX1, i have the successful message in SXI_MONITOR . However,. when i try to check the message in QE