Modify javascript with jsp

Hi.
Is there any way to modify a text within a javascript script using jsp?
I have all the javascript in a separated file.
Thanks.

Only if you make that separate file a JSP of course.

Similar Messages

  • Help me!! How to use JavaScript with JSP ??

    I am using JDeveloper and I created a screen in JSP which uses a bean for database connectivity and retriving info onto the page.
    The page has a ListBox where list items are populated from the database.My requirement is
    whenever the list is changed the page shuold be refreshed with the selected item info.
    I tried to use 'JavaScript' for triggering the event with 'onChange' event of the ListBox.But the event is not getting invoked. I think JavaScript is not working with JSP.
    Please help me with how to Use javaScript with JSP or any other alternative where I can meet my requirement.
    I have one more question...I have gone through the JSP samples in OTN and I am trying do download the sample 'Travel servlet' which show list of countries...etc
    I have also gone through the 'readme' but I don't know how to extract .jar file.
    I would be great if you could help me in this.
    Thanks!!
    Geeta
    null

    We have a similar need. We have used Cold Fusion to display data from Our Oracle Database. We have a simple SElect Box in HTML populated with the oracle data. When someone selects say the State of Pennsylvania. then we have an On change event that runs a Javascript to go get all the cities in Pennsylvania.
    Proble we are having is that inorder for the Javascript to work , we currently have to send all the valid data.
    Do you know of any way to dynamically query the the Oracle database in Javascript

  • Modify Collection with jsp:setproperty

    Hello:
    I have a problem with jsp and struts.
    I have a collection of items (List) and view the elments in jsp page. This It works fine.
    But the problem happens when i like modify the collection.
    The code to view the collection in jsp is:
    <jsp:useBean id="ItemListForm" class="com.myapp.struts.ItemListForm" scope="session" />
    <html:form action="/ItemEditAction" >
    <logic:iterate name="ItemListForm" property="listaItems" id="item" >
    <P>
    <BASEFONT SIZE="3">
    <jsp:getProperty name="item" property="etiqueta" />
    </BASEFONT>
    <P>
    <jsp:getProperty name="item" property="grafico"/>
    <P>
    </logic:iterate>
    <P>
    <html:submit>Save File</html:submit>
    <html:hidden property="do" value="saveXML"/>
    </html:form>
    The question is:
    How to modify the element "grafico" with jsp:setproperty.
    Thanks for all.

    Thank you, I had forgotten the set part, but then the next problem occurs:
    <jsp:setProperty name="date" property="locale" value="${locales.locale}"/>
    generates:
    org.apache.jasper.JasperException: Unable to convert string '${locales.locale}' to class java.util.Locale for attribute locale: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager
    could I only use Strings as input?

  • Best way to create, modify, XML with JSP ?  HELP

    Hi friends,
    As i am new to XML,
    I know there are two APIs used for XML processing, i want to know as a begineer level, which API
    is easy and good to implement XML with JSP.
    1) SAX
    2) DOM
    i want to make a log file in XML, so on web page it will be displayed on HTML form through XSL.
    Since there is good tutorial on http://www.w3schools.com/dom
    but i think its HTML dom
    I want XML procession through JAVA CODE , what should i use ? and give some good tutorials on XML DOM
    that is used with JAVA / JSP.
    HELP.
    Edited by: Ghanshyam on Sep 19, 2007 3:24 PM

    Well what i think is you gonna checkout with your requirements before implementing any of the popular XML parsing mechnisms.
    If you are intrested in faster processing @sacrifising a gud amount of your Memory,DOM is the one which you are looking for.
    If you are instrested in Managing your memory and but if you are ok with sacrifising speed SAX is the best solution.it works on what is called a push technology.
    and if you think either way you might have to look towards a pull parser which is StAX (Streaming API for XML Parsing)
    it'd be a gr8 idea if you can go through the below article which explians about each of the parsing mechanisms
    http://www.stylusstudio.com/xml/parser.html#*
    coming back to helpful resources as far java is concern checkout the below link which might be of some help.
    and the main thing is that all of these parser there is a defined specification you might find implementations of different vendors on this.
    eg:Sun Provides one with JDK itself,same as IBM provides one,oracle does the same & so on...
    your first task would be to focus on one such implementation which can cater your requirements.
    DOM:*
    Basic Parsing Objects / Interfaces Involved while DOM parsing:
    http://www.w3.org/TR/DOM-Level-2-Core/java-binding.html
    Breif Overview & few important API details:
    http://www.developerlife.com/domintro/default.htm
    Simple Example:
    http://www.brics.dk/~amoeller/XML/programming/domexample.html
    Others:
    http://www.roseindia.net/xml/dom/
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPDOM.html#wp79994
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/1_read.html
    SAX:*
    http://www.javacommerce.com/displaypage.jsp?name=saxparser1.sql&id=18232
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/index.htm
    http://java.sun.com/developer/Books/xmljava/ch03.pdf
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPSAX.html#wp69937
    http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=6
    StAX:*
    http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP2.html
    http://javaboutique.internet.com/tutorials/stax/
    http://today.java.net/pub/a/today/2006/07/20/introduction-to-stax.html
    Hope this might be of some help :)
    REGARDS,
    RaHuL
    http://weblogs.java.net/blog/spericas/archive/2006/04/sun_stax_parser.html

  • What is wrong with this javascript with jsp - asap help needed

    <script language="javascript">
    function checkSubmit(form){
                    // Loop from zero to the one minus the number of radio button selections
                    for (counter=0; counter < document.submitform.authortitle.length; counter++){
                        if (form.authortitle[counter].checked){
                            var splitStr = document.submitform.authortitle[counter].value;
                            alert(splitStr);
                            var splitStrArray = new Array();
                            splitStrArray = splitStr.split(","); alert(splitStrArray[2]);
                            splitStrArray[2].trim();
                            if(splitStrArray[2].equals("null")){
                                alert("true");
                                //replace the form action with somefile.jsp
                                document.forms[0].action="searchAmazon.jsp";
                                form.submit();
                            }else{
                                document.forms[0].action="isbnSearch.jsp";
                                form.submit();     
            </script>the above javascript method is acting stupid.. it shows the first two alerts but does not go in the if statement "if(splitStrArray[2].equals("null")){ " and does not show the third alert. i do not c any problems pls help... when i click the option and submit it gives me a jasper exception pointing to some line which does not involve this code...

    it has started working now basically the problem was the trim() method which i have removed and have changed .equals("null") to == ..
    BUT NOW it always does the else command and goes to the isbnsearch page even if the value is null (if null then it should go to another page)...

  • Associating two events with submit button using  javascript in jsp

    Hi
    How can i Associate two events with submit button using javascript in jsp. Firstly it should insert the data to database and secondly it should close the same pop-up window

    Have something like :
    <input type="submit" name="submitbtn" value="Click me" onClick="function1(); function2(); " />
    You just call both functions sequentially, it's that simple. Although using javascript to work with a database, that seems a bit tricky.

  • Problems with JSP in Firefox

    I have seen several references to this problem on this forum but no real solution on any of the pages I have found. My jsp, which right now is no more than a static HTML page with jsp as the extension so that I can add the java code later, will not display in firefox it only shows the source code when I go to my website. Some example code is below.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
         <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
         <title>
              Sichutech.com
         </title>
         <link rel="stylesheet" href="theme/NewMaster.css" type="text/css">
    </head>
    <body>
              <div class="spacer"> </div>
              <div id="banner" align="left">
                    <img src="images/logocropped.png">
              </div>
                        <br class="clearboth">
                        <div class="spacer"> </div>
                        <div id="row1col1" align="left">
                   <img src="images/home.png"><br>
                   <img src="images/mission.png"><br>
                   <img src="images/about.png"><br>
                   <img src="images/services.png"><br>
                   <img src="images/contactus.png">
              </div>
              <div id="row1col2" align="left">
                   <img src="images/worldwide.png"><br><br>
                   <p>
                        <b>Stand alone application development:</b><br><br>
                        We provide stand-alone application development for businesses of any size.
                        Our applications are developed in Java using best standards and practices.
                   </p>
                   <p>
                        <b>Web Development:</b><br><br>
                        We provide custom web development for businesses of any size. We use J2EE
                        technologies to develope all web applications. These technologies consist
                        of Java, Javascript, Java Beans, HTML, JSP, XML, and other technologies as
                        applicable.
                   </p>
                   <p>
                        <b>Questions:</b><br><br>
                        For a quote on a custom stand-alone or web application to meet your business
                        needs please contact us through the contact us page.
                   </p>
              </div>
              <br class="clearboth">
              <div class="spacer"> </div>
              <div id="footer">
                   Home 
                   Mission
                   About Us
                   Services
                   Contact Us
                   &#149;
                   Copyright &copy; Sichutech 2008 All Rights Reserved
              </div>
              <br class="clearboth">
         </body>
    </html>
    The website is up and running and displays fine in IE but not firefox. The site address is www.sichutech.com
    Any help is greatly appreciated.
    Thanks,
    Robert

    Here is what I see at the response headers:
    Date: Wed, 06 Aug 2008 02:37:52 GMT
    Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8b DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 mod_jk/1.2.25 mod_perl/2.0.4 Perl/v5.8.8
    Last-Modified: Mon, 04 Aug 2008 22:42:24 GMT
    Etag: "aa0088-602-453aa0d911400"
    Accept-Ranges: bytes
    Content-Length: 1538
    Content-Type: text/plain
    X-Antivirus: avast! 4
    X-Antivirus-Status: Clean
    200 OKNote the content type: it is text/plain instead of text/html. And FireFox interpreted it correctly as text/plain.

  • "Another program on your computer would like to modify Firefox with the following add-on" - how to disable?

    I am using the latest Firefox (28.0) on Windows XP in a shared computer environment. Although I do not have Administrator access, I installed Firefox myself and can change whatever Firefox config settings I want (including about:config and mucking with the files in the installation directory).
    I want to disable the tab that appears on Firefox startup, "Another program on your computer would like to modify Firefox with the following add-on". This tab usually appears once per day (the first time I startup Firefox each day). I want the tab not to appear at all, from now on.
    The "another program" in question is some program that is used in the facility where I'm using the computer, so I can't just uninstall that program. Although this is a shared computer environment, they don't "wipe" the machine every day, just reboot. So the Firefox I installed is still there with all my config settings intact. As far as I know, I'm the only person who uses Firefox on this computer.
    Solutions that don't work:
    "Just click Continue" -- but then I still see the "Another program" tab every day, and don't want to see it.
    "Click Remove in the Add-ons list" -- I removed the Add-on in question but the tab still appears every day.
    I would like a solution that either eliminates the Add-on request for that particular application, or eliminates all such requests ("Another program...") regardless of what application requested it. The ideal solution would be if the request itself had a checkbox for "never ask this again" but, alas, no such luck.

    Gosh... I spent about an hour preparing a response, then accidentally did control-something or alt-something which took me back a page and I lost everything I typed (even after I clicked Forward to try to get back to where I was). If anyone knows of a config setting like "don't ever trash an entire page of user input unless the user explicitly confirms it", or, "keep form input data even if the user goes Back or Forward", I think that would be a great feature.
    OK, back to the original question...
    I appreciate the responses thus far, but I think there have been some misunderstandings. Maybe a multiple-choice version would help:
    Question: Is there a way to suppress the appearance of the notification tab that says, "Another program on your computer would like to modify Firefox with the following add-on" (meaning, any request from another program to install an add-on is to be silently ignored and discarded)?
    Answer:
    (A) Yes, you can suppress that notification (please state how).
    (B) No, but you can request that feature (please state where).
    (C) No, you can't do that or request that feature.
    That's basically my question in a nutshell. If the answer is (B), I might envision a boolean about:config setting like "extensions.allowProgrammaticAddonRequests" that defaults to "true" and can be set to "false" manually. I think that would be the most direct solution (if it were possible).
    I will respond to some comments from above:
    "I don't understand why you are using a mozilla.cfg file to lock those preferences when you can modify the preferences for your current Firefox profile via about:config" -- This is because the "other program" in question (iCafe Manager) was setting certain config options (browser.startup.homepage, and browser.newtab.url) on every reboot (which happens every morning at that facility). I got tired of manually changing the settings back every day. Using the above-mentioned files, I successfully defeated iCafe Manager's daily interference with those config settings. The other things (like stuff related to Socks tunnelling) I probably could have just set once in about:config but doing a lockPref seemed to do no harm. The settings for "enabledScopes" and "xpinstall" were to see if they'd help with the problem I originally asked about, but they did not.
    "I would look in about:config to make sure those preference modifications are in effect" -- yes, I confirmed that the settings are in effect and locked. That much works as expected.
    "A) removing the iCafe Toolbar extension from the Firefox Addons -> Extensions panel results in the "Another program" tab at startup" -- true, but I think it would be more accurate to say: while the toolbar extension is not installed (due to either having been removed, or, never having been installed at all), the "Another program" tab appears on at least the first startup of Firefox after every reboot.
    "B) when you allow the installation it shows up as "(disabled)" in the Extensions list but the unwanted toolbar still shows up (correct?)" -- yes, correct.
    "You could explain the problem to the system administrator of your facility" -- unfortunately, there's no administrator on site, only a person who makes sure the lights are on. They'll call a tech if there's a catastrophic problem (like the net connection goes dead). Since I installed Firefox myself, and since iCafe Manager is a program they installed, I don't think they'll go out of their way to help me with Firefox (especially if I'm trying to defeat iCafe Manager's attempts to interfere with Firefox). From their point of view, their systems are working just fine.
    "allow the installation and then see if you can go to the Firefox Customize menu and HIDE the toolbar as a workaround" -- since I'm not in that facility now (and probably won't be again until this summer or so), I can't experiment with those systems now. But I do recall clicking just about everything I could, including "View - Toolbars" (which seems to be the same menu as when I right-click on a toolbar line). That menu allows hiding toolbars, but from my recollection, the offending toolbar was not displayed in the list, so I could not hide it that way. Also, the Customize menu ("View - Toolbars - Customize") seems to allow only modifications to a toolbar, and not a way to hide an entire toolbar.
    "it might help if you could post a new troubleshooting information list after you allow the iCafe Toolbar installation" -- ok, that troubleshooting report is included below.
    Thanks again for your help.
    Application Basics
    Name: Firefox
    Version: 28.0
    User Agent: Mozilla/5.0 (Windows NT 5.1; rv:28.0) Gecko/20100101 Firefox/28.0
    Crash Reports for the Last 3 Days
    All Crash Reports
    Extensions
    Name: iCafe Manager Toolbar
    Version: 5.2.0.6
    Enabled: false
    ID: {C058FE28-1E07-4FD1-8092-046F8A964D12}
    Important Modified Preferences
    accessibility.typeaheadfind.flashBar: 0
    browser.cache.disk.capacity: 358400
    browser.cache.disk.smart_size.first_run: false
    browser.cache.disk.smart_size.use_old_max: false
    browser.cache.disk.smart_size_cached_value: 358400
    browser.newtab.url: about:blank
    browser.places.smartBookmarksVersion: 6
    browser.sessionstore.upgradeBackup.latestBuildID: 20140314220517
    browser.startup.homepage: http://www.google.com/ncr
    browser.startup.homepage_override.buildID: 20140314220517
    browser.startup.homepage_override.mstone: 28.0
    dom.mozApps.used: true
    extensions.lastAppVersion: 28.0
    gfx.blacklist.direct2d: 3
    gfx.blacklist.layers.direct3d10: 3
    gfx.blacklist.layers.direct3d10-1: 3
    gfx.blacklist.layers.direct3d9: 3
    gfx.blacklist.layers.opengl: 3
    gfx.blacklist.stagefright: 3
    gfx.blacklist.suggested-driver-version: 6.1400.1000.5218
    gfx.blacklist.webgl.angle: 3
    gfx.blacklist.webgl.msaa: 3
    gfx.blacklist.webgl.opengl: 3
    network.cookie.prefsMigrated: true
    network.websocket.enabled: false
    places.database.lastMaintenance: 1398414928
    places.history.enabled: false
    places.history.expiration.transient_current_max_pages: 53428
    plugin.disable_full_page_plugin_for_types: application/pdf
    plugin.importedState: true
    plugin.state.npgoogleupdate: 1
    privacy.sanitize.migrateFx3Prefs: true
    privacy.sanitize.sanitizeOnShutdown: true
    storage.vacuum.last.index: 1
    storage.vacuum.last.places.sqlite: 1396778909
    Graphics
    Adapter Description: Intel(R) G33/G31 Express Chipset Family
    Adapter Drivers: igxprd32
    Adapter RAM: Unknown
    Device ID: 0x29c2
    Direct2D Enabled: Blocked for your graphics driver version. Try updating your graphics driver to version 6.1400.1000.5218 or newer.
    DirectWrite Enabled: false (0.0.0.0)
    Driver Date: 11-3-2008
    Driver Version: 6.14.10.5009
    GPU #2 Active: false
    GPU Accelerated Windows: 0/1 Basic Blocked for your graphics driver version. Try updating your graphics driver to version 6.1400.1000.5218 or newer.
    WebGL Renderer: Blocked for your graphics driver version. Try updating your graphics driver to version 6.1400.1000.5218 or newer.
    Vendor ID: 0x8086
    windowLayerManagerRemote: false
    AzureCanvasBackend: skia
    AzureContentBackend: cairo
    AzureFallbackCanvasBackend: cairo
    AzureSkiaAccelerated: 0
    JavaScript
    Incremental GC: true
    Accessibility
    Activated: false
    Prevent Accessibility: 0
    Library Versions
    NSPR
    Expected minimum version: 4.10.3
    Version in use: 4.10.3
    NSS
    Expected minimum version: 3.15.5 Basic ECC
    Version in use: 3.15.5 Basic ECC
    NSSSMIME
    Expected minimum version: 3.15.5 Basic ECC
    Version in use: 3.15.5 Basic ECC
    NSSSSL
    Expected minimum version: 3.15.5 Basic ECC
    Version in use: 3.15.5 Basic ECC
    NSSUTIL
    Expected minimum version: 3.15.5
    Version in use: 3.15.5

  • Running other server-side applications with JSP

    Hi,
    I'd like to know, if is possible run with JSP (Servlet, or JavaBean) other application, which support COM. I used something like this in JavaScript:
    application=new ActiveXObject("excel.application");
    and I had all possibilities of its API. I'd like to use excel as data source for user-friendly data input.
    Thanks for all suggestions

    Hi,
    I don't realy understand your question.
    If your javascript work using activeX, this code is executed on the client side (like the excel application and the excel file).
    You can, with a JSP, generate the html page that contain the script.
    Where is the problem ?

  • How can I create a Login-page with jsp???

    Hello,
    I have to create a page with JSP code on the Netweaver Developer Studio.
    But I do not know how I do it.
    Can anyone tell me what to write in the portalapp.xml?
    An example would be very helpful.
    Thank you
    Greetings

    As you can see in the example:
    The portalapp.xml file (deployment descriptor) provides configuration information for your application, and defines the components and services in your application. For each component and service, you specify the implementing Java class and configuration information.
    For more information on the format of the portalapp.xml, see Deployment Descriptor (portalapp.xml).
    <application>
        <application-config>
            <property name="SharingReference" value="com.sap.portal.navigation.service, com.sap.portal.navigation.api_mimeservice, com.sap.portal.navigation.helperservice"/>
            <property name="Vendor" value="MY_COMPANY"/>
            <property name="SecurityArea" value="PERMISSION"/>
        </application-config>
        <components>
            <component name="SimpleNavigationExample">
                <component-config>
                    <property name="ClassName" value="MY_CLASS"/>
                    <property name="SecurityZone" value="no_safety"/>
                </component-config>
                <component-profile/>
            </component>
        </components>
        <services/>
    </application>
    You can only update in this example, your class name and other details:
    <property name="Vendor" value="sap.com"/>
    <property name="SecurityArea" value="MyCompany"/>
    <property name="ClassName" value="LOGINCLASS"/>
    <property name="SecurityZone" value="no_safety"/>
    Modify this portalapp.xml file as follows:
           1.      NAVIGATION SERVICE, so you must add references to the following portal applications that define these services:
            com.sap.portal.navigation.service
            com.sap.portal.navigation.api_mimeservice
            com.sap.portal.navigation.helperservice
           2.      In the <application-config> section, create the following properties that help to define the security zone for all components and services in this application:
    ○     Vendor: String identifying the company or organization that provided the application, for example, sap.com.
    ○     SecurityArea: String identifying the security area for the application, for example, NetWeaver.portal.
           3.      In the <component-config> section for the mySiteMap component, create the property SecurityZone to define the specific security zone for the component.
    For Permission, check this document:
    http://help.sap.com/saphelp_nw04s/helpdata/en/44/489e2df5ee4e35e10000000a1553f6/frameset.htm

  • Use of Threads with JSP's

    Can you use threads in a web application that uses JSP's plus Servlets and Beans ?
    We have a JRUN 3.1 application using JSPs, Servlets and Beans. Shortly after we went live it became apparent that any 2 users using the same object experienced problems as one object was overwriting another. In a panic the problem was solved by whacking SYNCHRONISED on all objects.
    Now we want to write another application, are there strategies for using Threads with JSPs?
    Would this be part of the webserver configuration or would the application be coded in a certain way ?
    Please can you give me a simplistic answer or point me to some documentation that gives a simple overview.
    Thanks Steve

    Hi,
    You can use thread with jsp, i am sending u a example
    package thread;
    import java.io.Serializable;
    public class TaskBean implements Runnable, Serializable {
    private int counter;
    private int sum;
    private boolean started;
    private boolean running;
    private int sleep;
    public TaskBean() {
    counter = 0;
    sum = 0;
    started = false;
    running = false;
    sleep = 100;
    protected void work() {
    try {
    Thread.sleep(sleep);
    counter++;
    sum += counter;
    } catch (InterruptedException e) {
    setRunning(false);
    public synchronized int getPercent() {
    return counter;
    public synchronized boolean isStarted() {
    return started;
    public synchronized boolean isCompleted() {
    return counter == 100;
    public synchronized boolean isRunning() {
    return running;
    public synchronized void setRunning(boolean running) {
    this.running = running;
    if (running)
    started = true;
    public synchronized Object getResult() {
    if (isCompleted())
    return new Integer(sum);
    else
    return null;
    public void run() {
    try {
    setRunning(true);
    while (isRunning() && !isCompleted())
    work();
    } finally {
    setRunning(false);
    And JSP page start.jsp
    <% session.removeAttribute("task"); %>
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <% task.setRunning(true); %>
    <% new Thread(task).start(); %>
    <jsp:forward page="status.jsp"/>
    ///////////////// status .jsp
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <HTML>
    <HEAD>
    <TITLE>JSP Progress Bar</TITLE>
    <% if (task.isRunning()) { %>
    <SCRIPT LANGUAGE="JavaScript">
    setTimeout("location='status.jsp'", 1000);
    </SCRIPT>
    <% } %>
    </HEAD>
    <BODY>
    <H1 ALIGN="CENTER">JSP Progress Bar</H1>
    <H2 ALIGN="CENTER">
    Result: <%= task.getResult() %><BR>
    <% int percent = task.getPercent(); %>
    <%= percent %>%
    </H2>
    <TABLE WIDTH="60%" ALIGN="CENTER"
    BORDER=1 CELLPADDING=0 CELLSPACING=2>
    <TR>
    <% for (int i = 10; i <= percent; i += 10) { %>
    <TD WIDTH="10%" BGCOLOR="#000080"> </TD>
    <% } %>
    <% for (int i = 100; i > percent; i -= 10) { %>
    <TD WIDTH="10%"> </TD>
    <% } %>
    </TR>
    </TABLE>
    <TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>
    <TR>
    <TD ALIGN="CENTER">
    <% if (task.isRunning()) { %>
    Running
    <% } else { %>
    <% if (task.isCompleted()) { %>
    Completed
    <% } else if (!task.isStarted()) { %>
    Not Started
    <% } else { %>
    Stopped
    <% } %>
    <% } %>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="CENTER">
    <BR>
    <% if (task.isRunning()) { %>
    <FORM METHOD="GET" ACTION="stop.jsp">
    <INPUT TYPE="SUBMIT" VALUE="Stop">
    </FORM>
    <% } else { %>
    <FORM METHOD="GET" ACTION="start.jsp">
    <INPUT TYPE="SUBMIT" VALUE="Start">
    </FORM>
    <% } %>
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    ////////////////////////////// stop.jsp
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <% task.setRunning(false); %>
    <jsp:forward page="status.jsp"/>
    deploy it into ur server and run start.jsp
    and see whatb happens

  • Help a new guys with JSP!

    Hi,
    i'm a new programer with JSP.
    I've created a class files that connect a database.
    But i would like to know how to write text with JSP?
    I would like to write a 'thank you' message after saving a form in a database.
    does its possible to have it in my class files?
    thanks for your help.

    Im not an expert on jsp or java but i will try to give my ideas.. i hope i can help you =)
    /* you could actually forward your servlet to your confirmation file like this : */
              ServletContext sc = getServletContext();
    .// just fill up here the variable msg , u cud write to its value your thank you message or something else like error messages
              RequestDispatcher rd = sc.getRequestDispatcher("/Confirmation.jsp?msg="+msg);          
              rd.forward(req, res);     
    /******* or u cud also throw ur request to the same jsp and display the ***/
    /******* message thru a form tag using javascript like this : ***/
    suppose your main jsp is this:
    <html>
    <head>
    <STYLE TYPE="text/css">
         .noBorder{
              border: white 0px solid;
              background-color: white;
              font-family:Arial;
              font-size:13px;
              font-weight: bold;
              color:green;
              width:300px;
              text-align:center;
    </STYLE>
    </head>
    <%!
    Connection conn;
    PreparedStatement pstmt;
    private doInsert(String name){
    // this is an oracle connection
    String sql = "INSERT INTO TABLENAME(FIELD1) VALUES(?)"
    try{     
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // just fill up the dburl , dnusername and dbpassword
    conn = DriverManager.getConnection(dburl,dbusername,dbpassword);
    pstmt = conn.prepareStatement(sql);
    pstmt.clearParameters(); // clear any previous parameter values
    pstmt.setString(1,name);
    pstmt.close();
    }catch(SQLException se){     
    }catch(Exception e){          
    }finally{
    if(conn!=null){
         try{
         conn.close();
         }catch(SQLException se){}
    %>
    <body>
    <form method=post"" name="msgscr">
    <tr><td colspan="2"><input type="text" name="msg" value="" class="noBorder" disabled/></td></tr>
    </form>
    <%
    if(request.getParamater("submit")!=null){
    // you could also add a return value for doInsert method to check whether the dbase insertion
    // is successful or not if the return value is true then the value for the document.msgscr.msg.value
    // is thank you otherwise u cud put "Unable to process your request" or other message
    doInsert(request.getParameter("name"));
    out.println("<script>document.msgscr.msg.value='Thanks you!!!!';</script>")
    %>
    <!-- this means that the request qill be thrown on this file-->
    <form method="post">
    <tr>
    <td>NAme : </td>
    <td><input type="text" name="name" value=""/></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit " value="Submit"></td></tr>
    </form>
    </body>
    </html>     
    /**** or you could also do the confirmation message just by adding an **/
    /**** alert message using javascript like this: **/
    <head>
    <script language="javascript">
    function ValidateCreate(theform){
         if(theform.name.value==""){
         alert("name is required");
         return false;
         }else{
         alert("Thank you!!!!");
    return true;
    </script>
    </head>
    <body>
    <form method="post" onsubmit="return ValidateCreate(this)">
    <tr>
    <td>NAme : </td>
    <td><input type="text" name="name" value=""/></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit " value="Submit"></td></tr>
    </form>

  • HTML-FRAMES with jsp as sorce

    Hi,
    I use a HTML with 5 FRAMES, 2 of them with jsp-files as src.
    How can I pass data to these jsp-files before the servlet calls the HTML?
    Is this possible at all?
    Thanks a lot

    you can reference and set hidden input values inside another frame by referencing them in javascript function. afterwards, submit the form ...
    function submitInfo() {
    top.frames["frameName"].document ... // branch for NS and IE
    document.forms["currentForm"].submit();
    }

  • Authentification and Security in WebApp with JSP

    Hello to all.
    I'm developing a Web Applications with JSP's. To use the application a user must first Login.
    To restrict access via URL typing I have included in every JSP page a user_logged_in_check page that verifies that the user is logged in, and if not redirects to the Login page.
    The problem is that I must not forget to include that page in all my JSPs, and if the name of the page changes, it must be changed everywhere (though a search/replace might do the job just fine).
    I used this approach because is not server dependent (such as the Tomcat Realms example I have seen on this forum).
    Is there a better strategy?
    Is there a way to enforce security check and not rely on my attention ;)?
    Is there a pattern that solves the problem?
    Any help would be greatly appreciated.

    The first and biggest disadvantage is the repetitive coding - what happens if you realise that you need to change something - you will need to modify each of your JSP files. The chances of someone forgetting to add it in are a security risk.
    Secondly, using the web server's mechanism, in most cases, would mean that you are using a proven and much more stable security mechanism then you can whip up.
    For example, in Weblogic, you can configure a JAAS provider -- that means you are not limited to using uname/password. Your customer may have an enterprise wide single sign on policy that is supported by the JAAS provider and you can use it straight away - by just making a declarative change in the web*.xml files.
    If you must, use the Filter class (its a Servlet class, I checked after I had posted) as described in the Intercepting Filter pattern - at least thats a standard approach and will cut down on you having to rely on adding a snip of code to each of your JSPs.

  • JavaScript within JSP

    Hi all !!
    I'm stuck up.
    Is there any way by which i can actually embed JavaScript within a JSP file that contains no JSP code. Actually it is file with .jsp extention but from within it holds only java script inside <script> tags.
    The prerequisite is there should be no performance implications... as this would be just a plain js file anyways.
    I need this coz i want to pick-up messages for alert from Resource bundle. For this i'am using <bean-el:message ...> tag. but using this in a plane .js file is not possible.
    How should i go about it.
    or
    Is there any better way to do this.

    You could put how much ever js that you need inside a jsp file. Theres no restrictions and given that you have to pick up messages using a tag, there's no other way out too.
    Other than the compilation time (which can be overcome by precompiling jsps), there's not much of a difference in the load time for a static html or html streamed from a jsp process. Ofcourse if you use the 'src' tag to load you js, each 'src' results in a round trip. However that's true of even static html pages.
    cheers,
    ram.

Maybe you are looking for