How declara a method in my jsp code?

I have the following method.
Somebody knows as there is to declare it in my jsp code?
Thanks.
public String reemplaza(String i,String ci,cf)
String o=i;
while(o.indexOf(ci)!=-1)
{ o=o.substring(0,indexOf(ci))+cf+o.substring(indexOf(ci)+ci.length(),o.length()); }
return o;
}

Compare the codes and you see the errors.
//Before(with errors)
public String reemplaza(String i,String ci,cf)
String o=i;
while(o.indexOf(ci)!=-1)
{ o=o.substring(0,indexOf(ci))+cf+o.substring(indexOf(ci)+ci.length(),o.length()); }
return o;
//After(with no errors):
public String reemplaza(String i,String ci,String cf)
String o=i;
while(o.indexOf(ci)!=-1)
{ o=o.substring(0,o.indexOf(ci))+cf+o.substring(o.indexOf(ci)+ci.length(),o.length()); }
return o;

Similar Messages

  • How to use enviroment variables in JSP code?

    I�m developing a web server with JSP�s, and I need to move the application to others computers. I need to access to a directory, but I don�t know it because the user can install the Application in the directory he wants. So I need to access to that directory in the JSP code.
    The directory is "C:\Program Files\....\tomcat\webapps\ROOT\upload". I have the CATALINA_HOME enviroment variable defiened as "C:\Program Files\....\tomcat\", so I need to use something like "CATALINAHOME\\webapps\upload\", but I don�t know how to mekr the JSP code to understand the enviroment variable CATALINA_HOME.
    I�ve tried with %CATALINA_HOME%, but the Tomcat server doesn�t recognize it. How can I access to that directory?
    Thanks (Sorry about my english)

    My JSP�s are in: %CATALINA_HOME%\webapps\ROOT\
    I wan�t to access to %CATALINA_HOME%\webapps\ROOT\upload\
    My JSP code:
    <% ...
    String DPATH = "C:\\Program Files\\JBuilder7\\jakarta-tomcat-4.0.3\\webapps\\ROOT\\upload\\";
    File newfile = null;
    newfile = new File(DPATH+filename);
    %>
    I want the JSP to locate the directory \webapps\ROOT\upload\ without knowing the complete route "c:\Program Files\...", because I have the enviroment variable CATALINA_HOME with the value "C:\Program Files\JBuilder7\jakarta-tomcat-4.0.3\". SO the user of the aplication only has to set the CATALINA_HOME variable and the aplication should access the upload directory throught the CATALINA_HOME variable.
    I can�t explain it better. Sorry.

  • How can I reach Javascript from JSP code blog?

    <script>
    var name2; // want to reach the data which in JSP code blog
    </script>
    <body>
    <%
    String name; // a data from database
    %>
    </body>Simply I want to reach "*name*" valuable from Javascript..
    I'll be happy if someone helps me..
    Thanx in advance..
    Talha

    Just print it out as a Javascript variable. Carefully read this: [http://balusc.blogspot.com/2009/05/javajspjsf-and-javascript.html].

  • How to use protected method in jsp code

    Could anyone tell me how to use protected method in jsp code ...
    I declare a Calendar class , and I want to use the isTimeSet method ,
    But if I write the code as follows ..
    ========================================================
    <%
    Calendar create_date = Calendar.getInstance();
    if (create_date.isTimeSet) System.out.println("true");
    %>
    ============================================================
    when I run this jsp , it appears the error wirtten "isTimeSet has protected access in java.util.Calendar"

    The only way to access a protected variable is to subclass.
    MyCalendar extends Calendar
    but I doubt you need to do this. If you only want to tell if a Calendar object has a time associated with it, try using
    cal.isSet( Calendar.HOUR );

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • HOW TO CALL A JSP METHOD FROM ANOTHER JSP

    Hi all, I have to JSP1 and JSP2 and i would like to call a method of JS1 from JSP2. Is that possible ??
    Example:
    JSP2 Code
    somewhere in the code ...
    String s = JSP1.getName();
    out.println("EL NOMBRE ES " +s );
    thanks in advance for your help

    No, it is not possible. Infact you cannot write your own methods in JSP. What ever you write in a jsp page is part of _jspService() method. Secondly how can you instantiate another class(generated by JSP), until or unless you know the name of the class that resulted from your JSP. Your JSP page is first converted into .java file which is stored in some package e.g.
    pagecompile.jsp._yourJSPfile.
    I couldnot understand why you need to invoke a method of another JSP in your JSP.
    Hope this helps

  • How to write JSP code in Java Script Code

    Hello friends
    I have code like
    <script language="JavaScript">
    function f()
    (some code is here)
    </script>
    Now i wants to put some JSP code in f()
    So can i do this ? IF yes then how ?
    (one solution may be make JSP function and call that JSP function from the f().So in that case how can i call JSP function from JavaScript??
    If other method is there then please mail me

    If it's a simple matter of mixing client-side code with server side code, it can be done so long as you're using the server-side to write the client-side.
    For example:
    <h1>Good Morning Mr. Phelps</h1>
    <input name=anybodyFunction type=text>
    <% if (userIsAdmin) { %>
    <input name=adminOnlyFunction type=text>
    etc.
    <% } %>
    <h1>This browser will self-destruct in ...</h1>
    That's JSP (inside the <% %>) mixed with HTML.
    Javascript goes 100% on the client-side. If you're writing JSP with inter-mixed HTML, you might have to inter-mix the java-script.
    For example: Suppose you need to validate the form. "adminOnlyFunction", among others, is a mandatory field, and you want the Javascript to only submit the form if all mandatory fields are set. Well, if the user is NOT an administrator, then that field WILL be left blank.
    One way to handle that is with mixing JSP/HTML/Javascript on the SERVER side.
    <h1>Good Morning Mr. Phelps</h1>
    <input name=mandatory1 type=text>
    <input name=optional1 type=text>
    <% if (userIsAdmin) { %>
    <input name=adminOnlyFunction type=text>
    <% } %>
    <input name=submit type=button value=Submit onClick="checkit()">
    etc. etc.
    <script language=Javascript>
    function checkit() {
    var f = document.form;
    if (
    � � f.mandatory1.value == ""
    � � || f.mandatory1.value == ""
    � � || f.mandatory2.value == ""
    <% if (userIsAdmin) { %>
    � � || f.adminOnlyFunction.value == ""
    <% } %>
    � � � � ) {alert ("Hey! You left out a required field!!");}
    etc. etc. etc.
    I imagine THIS might be what is meant by "mixing JSP with Javascript", and in this particular fashion, it can be done. What you're doing is making decisions on the server side over what to write out to the client. That client code can make further decisions based on user input.
    However, once it's on the client side, you can not have anymore JSP code. The client NEVER runs JSP code.

  • How to call a method repeatedly with JSP custom tag?

    This senerio is very similar to the usage of StringBuffer.
    I have a problem which can be solved easily with scriptlets:
    <% NameValuePair nvp = new NameValuePair(request.getQueryString()); %>
    <a href="foo.html?<%=nvp.add(name1", "value1").add("name2", "value2").toString();%">">Foo</a>
    <a href="bar.html?<%=new NameValuePair(request.getQueryString()).add("x", 1).add("y", 2).toString()%>">Bar</a>
    But I cannot use scriplets because it's turned off. I can only use jsp custom tag / jstl. How would I implement this functionality with a custom tag? How would the JSP code look like? Our container supports JSP 2.0.
    Thanks.</a>

    hi,
    you can do within 2 step-
    1) use <%@page import="your_java_class"%>
    2)use scriptlet code <%...%> and write coding in this tag.
    means create instance of your java class .
    <% your_java_class obj1=new your_java_class();
         obj1.method_of_your_java_class();
    %>or
    3) you can make javabean to use method of java class.[Best option]
    Thanx
    Ranvijay

  • How to close a window of IE7 using jsp code

    Hi,
    Can any one suggest how to use window.close method for closing a window of IE7 , presently i am using below code for logging off a page but i am recieving an error saying object expected and some text undefined , can any one let me know what extra code is required to be added in below jsp code  for logging of a window in  IE7
    function logoff()
            if (EPCM.getUAType() == EPCM.MSIE)
                window.returnValue = 'logoff';
            else
                window.opener.logoff();
            closeWindow();
        function closeWindow()
            window.close();
    Thanks
    Abhai

    Hi Abhai,
    In your javascript, you can add a try catch block to check which object is null.
    Also check this:
    Portal user often can't log off because of the Log off window was blocked
    Greetings,
    Praveen Gudapati
    p.s. Points are always welcome for helpful answers

  • How to access a JAVA Script variable in JSP Code

    How to access a JAVA Script variable in JSP Code. I have been unable todo this.
    Plz Suggest a way.
    Thanks
    Soumya

    try to do this code
    String s=request.getParameter("javascriptvariablename");

  • How to get OutputStream/Writer for a file in a JSP code?

    In a JSP code as shown below, how could we get an OutputStream to write a file that resides on the server file system?
    I'm stuck after five hours struggle!
    <%
    /* simple experimental JSP program */
    ...  // get request data
    Properties pt = new Properties();
    Class clas = getClass();
    InputStream is = clas.getResourceAsStream("/users.properties");
    pt.load(is);
    String userNameDB = pt.getProperty("user");
    String passwordDB = pt.getProperty("password");
    long lastLogonDB = Long.parseLong(pt.getProperty("lastLogon"));
        // so far so good ...
    if (userName.equals(userNameDB) && password.equals(passwordDB)){
      if (lastLogonForm > lastLogonDB) {
        session.setAttribute("User", userName); //Saves user name string in the session object
        pt.setProperty("lastLogon", lastLogon);
        pt.setProperty("user", userNameDB);
        pt.setProperty("password", passwordDB);
        ...  // how to write back the new data to the users.properties file?
    %>

    I have found a solution:
    String path = application.getRealPath("/users.properties");
    InputStream is = new FileInputStream(path);
    is.close();
    OutputStream os = new FileOutputStream(path);
    os.close();getResourceAsStream() is oddly incompatible with the code using the getRealPath(). So don't use it.

  • How do I find the jsp code behind an Oracle EBS page

    Hello,
    I have not worked with Oracle EBS in about 3 years and am somewhat new to JSP. I am trying to figure out how it all works and would like to go from the front end Oracle EBS screen to the source code jsp file.
    I was able to find the queries behind the screen by clicking on the about page link. I was aslo able to find plenty of jsp files in the OA_HTML directory on the server but I was not able to line any of them up with an EBS page on the front-end of Oracle apps.
    With Oracle forms it seems much simpler when I just easily get the form name from the screen (Help->About Oracle applications) and then just open up the corresponding fmb with the same name.
    How do I find this corresponding jsp file?
    Thanks

    Credit cards have security codes on them, either on the back on the signature strip or some cards have it on the front : credit card security code. None of the gift cards that I've bought have had a security code on them

  • How to execute again the JSP codes

    Dear Experts,
    I am having trouble to execute again the JSP codes in my abc.jsp page. The sequence of the codes are:
    [ JSP codes ]
    [ HTML codes]
    My JSP file is selecting from DB2 and display the results on the same page. The selecting is depending to the selection in the combo box and included the selection into the SQL statement.
    The problem is when I change the selection at the combo box, how can I refresh the page and fill in with the new results from database by selecting with the new keyword.

    You will have to do an onChange handler for the select box, that simply submits the form, and the action would be the current page.

  • How to compile and deploy JSP code from Unix server command line?

    I am new to JSP technology. We are thinking to modify some of JSP code to meet our need. But I am not sure what I should do after I change JSP code. How can I compile the changed code? How to deploy? How to publish on the web?

    All files are regenerated if changed.
    That goes for the .java and the .class files that are created. The jsp server checks to see if the current version is the latest. If it is, nothing gets changed or recompiled. If things are different, programs are recompiled.
    Youll notice that if you have a new jsp it always takes longer the first time. Or even when you change a jsp, the first time takes the longest for the page to come up in a browser. This is because of recompiling.
    Does this make any sense?
    Adam

  • How can we prevent viewing the source code  of JSP by the user

    Dear sirs,
    how can we prevent viewing the source code by the user ( from the browser for the Viwe Sorce option) for a JSP file that use struts frame work.
    infact i don't wan the user to view the javascript that in incorporated in the JSP for various purpose...
    thanks and regards...
    Sudheesh K S
    INDIA

    Dear sirs,
    how can we prevent viewing the source code by the
    user ( from the browser for the Viwe Sorce option)
    for a JSP file that use struts frame work.
    infact i don't wan the user to view the javascript
    that in incorporated in the JSP for various
    purpose...
    thanks and regards...
    Sudheesh K S
    INDIAJSP and Servlets are programs/scripts that run on the server. The user/clients only sees the HTML output generated by the server. If you want to hide JavaScript from casual users then you can put the JavaScript code in a seperate file. This file can however be read from the Cache.

Maybe you are looking for

  • Do SD card readers not work with 10.3?

    I have an old G4 Power mac, and my kids have iMac G5s. We all run 10.3.9, and have SD card readers, and none of them work at all. Does Apple acknowledge that SD cards do not work with Macs, and/or was this fixed in 10.4? We are looking to replace our

  • H85M "Gaming" with g3258, OC genie doesn't work

    Hi I just got a H85M after seeing it on sale and seeing that it had OC genie. I hear these g3258s are great for overclocking, I wouldn't know as OC genie  doesn't change my clock frequency in the the slightest, add to that no manual over clock (which

  • How do you create a bootable image accessable via OPTION at boot time...

    Hello. Is there a way to create a 'bootable image' of a hard drive and save on my raid and access it via the OPTION menu (hold option key at boot)? I would like to create a OSX bootable drive and then save the whole thing in a file. That way I can se

  • SAP Install on Solaris 10 Sparse Root Zone ../usr/sap

    Hi All, I was wondering if anyone is running SAP on Solaris 10, SAP EHP4 ECC 6.0 Oracle DB version 10. App and Db in a sparse root zone. When we initially created our SAP install the Directories containing <SID> and trans_<SID> was give to us as "/us

  • How do I create multi colored boxes using CSS3

    OS - Windows 7 using DW Cs5.5 I need to create a screen with lots of equally sized colored boxes with text colours that will be visible easily within them. I have a class set up as follows: .yellowbox {     font-family: "Lucida Sans Unicode", "Lucida