Dynamic HTML elements with JSP?

I need to have a row in a HTML page which contains of a combox and two text fields.
Depending on what I select in the combox I have to insert another row (which contains another combox and two text fields) or I have to remove one or both text fields from the current row.
Is that possible with JSP?
Many thanks

You can certainly accomplish what you're asking for in a jsp. One of the tricks you can use to solve your problem would be to pass variables back into the page using the Get method and catching the values using the request.getParameter() technique. One quick tip, you should wrap any request.getParameter() elements with a try catch, if you try to grab a parameter that hasn't been defined yet (and this is perfectly acceptable) you'll get a null returned.
I hope this helps

Similar Messages

  • Can't create dynamic html elements with jsp????? important

    Hi All,
    I am having problem creating dynamic html elements with jsp tags, i have tried to use EL and java scriplet, both of them don't work.
    i am trying to create dynamic menu in my "rightMenu.jspf", based on, if user has logged in or not.
    some like this!
    <jsp:if test ="${validUser == null}">
    some simple text menu here
    </jsp:if>
    but it is not working. it simply loading all and images with in statement, regardless of whether user has logged in or not. i think some how if statement is not working properly.
    "validUser" is a session bean, which is not creating at this point, it will created when user will log in successfully. and also this session bean does not exist at the page, where i am trying to check that .
    Is there any way to create dynamic values in jsp. It is really important, is there any body who help me in this matter. i would be really grateful.
    zaman

    hi jaspre,
    thanks for replying me. you know what, is it not something wrong with web.xml file. i remember once, i deleted some from there, a property with "*.jsp". i can't remember what exactly was it though.
    all if statements works on files ending with extension ".jsp" but don't work only on with extension ".jspf". there must be to do with this.
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <servlet>
    <servlet-name>ValidateServlet</servlet-name>
    <servlet-class>ValidateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ValidateServlet</servlet-name>
    <url-pattern>/ValidateServlet</url-pattern>
    </servlet-mapping>
    <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>pollAndCometEnabled</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
         <welcome-file>
    main.jsp
    </welcome-file>
    </welcome-file-list>
    </web-app>
    if any one can figure it out. i would be grateful.
    zaman

  • How can i render a dynamic html file in jsp page

    Hi everybody,
    i am trying to render a dynamic html file in jsp page with the result of querying a database.
    The response of the query is a xml document. And i have a stylesheet to transfer it to html.
    How can i render the html in a jsp file?

    I am using below code for HTML files
    private var appFile:String="index.html";
    if (StageWebView.isSupported)
                        currentState = "normal";
                        webView.stage = stage;
                        webView.viewPort = new Rectangle( 10, 130, (stage.stageWidth)-20, 750 );
                        var fPath:String = new File(new File("app:/assets/html/aboutus/"+ appFile).nativePath).url; 
                        webView.loadURL(fPath);
                        addEventListener(ViewNavigatorEvent.REMOVING,onRemove);
                    else {
                        currentState = "unsupported";
                        lblSupport.text = "StageWebView feature not supported";
    above code is working fine for me.

  • Building HTML page with JSP from different applications

              Hi,
              we need to build a HTML page with 2 JSPs. If both JSP were in the same Application
              (Weblogic 8,1) there is no problem. But I have to use JSPs from differents web
              applications, each JSP is in different war files.
              How can I compose this page? How can I management the request object?
              thanks
              

    Your program print the whole jsp source code??
    This is your web server configuration problem.
    Your web server handle your jsp page like text file only.

  • 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();
    }

  • I have firefox 21.0. For some reason, it's not resizing html elements with Javascript. When I use getElementById, it ignores the changes I try to make.

    I've tried resizing and repositioning the element with this code:
    <pre><nowiki>widthPercentage = screen.availWidth / 800;
    heightPercentage = (screen.availHeight / 600);
    squareLeft = (124* widthPercentage);
    squareTop = 202;
    if (document.getElementById)
    TEMPO = document.getElementById('SQUARE');
    TEMPO.style.left = (124 * widthPercentage);
    I've tried with this code:
    squareTop = 202;
    squareLeft = (124 * widthPercentage);
    starterWidth = (495 * widthPercentage);
    starterHeight = (99 * heightPercentage);
    TEMPO = '<DIV ID="SQUARE" STYLE="position:absolute; left:squareLeft; top:squareTop; visibility:visible;">';
    TEMPO += '<P>';
    TEMPO += '<img name="screenTitle_box" ID="STARTER" src="ARTWORK/FRONT_SCREEN_TITLE_5.JPG" HEIGHT=starterHeight WIDTH=starterWidth>';
    TEMPO += '</P>';
    TEMPO += '</DIV>';
    document.getElementById('SQUARE').innerHTML = TEMPO;
    Neither way works. But the same code works in Internet Explorer.
    Here's the element I'm trying to manipulate:
    <DIV ID="SQUARE" STYLE="position:absolute; left:333px; top:10px; visibility:visible;">
    <P>
    <img name="screenTitle_box" ID="STARTER" src="ARTWORK/PICTURE_5.JPG" HEIGHT="150" WIDTH="900">
    </P>
    </DIV></nowiki></pre>

    A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.
    *http://forums.mozillazine.org/viewforum.php?f=25
    The helpers at that forum are more knowledgeable about web development issues.<br>
    You need to register at the MozillaZine forum site in order to post at that forum.

  • Converting an html file with jsp contents to a text file for download

    Hi guys,
    I'm currently having troubles with downloading a .jsp file to a doc file.
    The thing is i am able to download the desired file and make it as a .doc but when i open it with ms word 2007 i can only see the content of the html. The dynamic content generated from the database and reflected on the .jsp page that i suppose to download and convert to .doc file doesn't show.. I hope someone could help me... My servlet code is this:
    public class FileDownload extends HttpServlet
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    try
    String originalFileName="localhost:8080//Appsdev//reportresults1.jsp";
    File f=new File(originalFileName);
    System.out.println("THE 1st f:"+f);
              response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename=tryreport.doc;");
    response.setHeader("Cache-Control", "max-age=0");
    byte[] buf = new byte[1024];
    FileInputStream inStream = new FileInputStream(f);
    OutputStream outStream = response.getOutputStream();
    int sizeRead = 0;
    int size = 0;
    while ((sizeRead = inStream.read(buf, 0, buf.length)) != -1)
    outStream.write(buf, 0, sizeRead);
    size += sizeRead;
    inStream.close();
    outStream.close();
    catch(Exception e)
    e.printStackTrace();
    }

    Hi BalusC,
    sorry for the double post i'm newly registered and it's my first post before i was just reading other's threads.
    well last night while i was reading and researching for a solution a came across this.
    <%@ page language="java" contentType="application/msword"%> naturally for my other jsp pages, the contentType is text/html so when the page loads it display in the browser. But with application/msword when i direct the page to the jsp page that i want to download and set the contentType with that...it prompts a window like when you're downloading the one with the <open with and save as>. It works fine to, i was able to see the report that i have to download and it is formatted very much like what i am seeing on the browser. My only concern now is the file i am able to download is a .jsp file how could i change that to a .doc file and be able to see the same content like the one with the .jsp file that i have right now.... any help or examples would be greatly appreciated. I didn't use the servlet anymore because even though i am able to download there is no content the html parts only but iam able to change the extension for the file...thanks again! ^ ^

  • Sending a html email with jsp

    is it possible to send an email with html content and how do i do that

    Try this
    <%@ page import="sun.net.smtp.SmtpClient,java.io.PrintStream" %>
    <%
    try{
    String host = "IP"; //this is u r IP adress
    String from = "[email protected]"; //mail adress of sender
    String to = "[email protected]"; //mail address whom to
    SmtpClient smtp = new SmtpClient(host);
    smtp.from(from);
    smtp.to(to);
    PrintStream out1 = smtp.startMessage();
    out1.println("To: " + to);
    out1.println("Subject: Hello peter ");
    out1.println();
    out1.println("Hi Peter How r u doing ");
    out1.flush();
    out1.close();
    smtp.closeServer();
    catch(Exception e)
    out.println(e+e.getMessage());
    %>

  • HTML email with JSP

    Hi I've been working an an email bean for some time now. I have got almost everything working. I am just getting hung up on formating the email. I want my email to be in HTML so that I have more control over the formating. To that end my message is set up as
    msg.setContent(message, "text/html"); in my class file.
    My JSP page is as follows.
    <html>
    <%@ page import="sendmail.SendMail"%>
    <body>
    <%String to = "[email protected]";%>
    <%String from = "[email protected]";%>
    <%String subject = "Test E-Mail through JSP";%>
    <%String message = "<h1>This is a test of sending a  plain text e-mail through JSP.</h1><br> Here is line 2.";%>
    <jsp:useBean id="sendEmail" class="sendmail.SendMail" scope="session">
    <jsp:setProperty name="sendEmail" property="to"  value="<%=to%>" />
    <jsp:setProperty name="sendEmail" property="from"  value="<%=from%>" />
    <jsp:setProperty name="sendEmail" property="subject"  value="<%=subject%>" />
    <jsp:setProperty name="sendEmail" property="message"  value="<%=message%>" />
    </jsp:useBean>
    <%
    sendEmail.sendEmail();
    %>
    The page displayed.  Did the email send?
    </body>
    </html>The email that this page is sending is in HTML format, but the formating is not evident in the message. I'm sure that I'm missing something very minor but for the life of me I can't figure it out. Any help would be appriciated. Thanks.
    Never mind. It turns out that this was caused by me seting the bean to a session type. When I stopped and started Tomcat it worked fine. So I changed the bean to request and it is working fine now.
    Edited by: Millisa on Apr 30, 2008 9:55 AM

    Try this
    <%@ page import="sun.net.smtp.SmtpClient,java.io.PrintStream" %>
    <%
    try{
    String host = "IP"; //this is u r IP adress
    String from = "[email protected]"; //mail adress of sender
    String to = "[email protected]"; //mail address whom to
    SmtpClient smtp = new SmtpClient(host);
    smtp.from(from);
    smtp.to(to);
    PrintStream out1 = smtp.startMessage();
    out1.println("To: " + to);
    out1.println("Subject: Hello peter ");
    out1.println();
    out1.println("Hi Peter How r u doing ");
    out1.flush();
    out1.close();
    smtp.closeServer();
    catch(Exception e)
    out.println(e+e.getMessage());
    %>

  • Sort a HTML table with JSP

    Hi,
    I have a Read-Only-Table and I want when the user click in the table-headers-colums, the table be re-order.
    This is possible ?
    Tank´s.

    Are you using ADF BC for the persistence?
    If you do then you can expose a method in the AM that recieves a column name as a parameter and uses the view-object's setOrderByClause() method to reorder the data and display it in the page.

  • Rewrite a complete HTML page with all result inside with JSP

    i have generate a HTML page with JSP. Then by an action on a menu on the left frame,i have to rewrite this page with the data already seized, and more code inside(i.e complete the page).
    How can i do ?

    Use JavaScript to tell the other frame to reload or to go to another location. Generate the JavaScript if you're processing a request of the menu...

  • 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.

  • How to include HTML file in JSP using HTML elements or Javascript?

    Hi,
    I have around 15000 static html files one for each item which we display each upon invoking an item.The HTML file should be part of a JSP file.
    Please note that the name of the HTML file is determined dynamically
    Placing all the HTML files within the web application does not give us good performance so i would like to put all of them in the webserver.
    I am not able to include the file in the JSP using the jsp:include attribute if i place the HTML files in the webserver ,
    in order to do that i think should use either HTML element or javascript to include the HTML in the JSP.is there any alternative to <Jsp:include>
    Does anyone have an idea how to include the HTML file and take advan tage of webserver?
    Any ideas are appreciated

    What you need to do is simply read the HTML file from the disk and dump it out to the outputstream. It really is that simple.
    There's no reason you need to include all 15000 files in the actual WAR, you can place those files any place handy that is easy for the application to see (in another directory, or accessible from a file server if you have multiple front ends).
    Then, just write a utiility function that takes the output stream (i.e. the 'out' JSP variable), and the file name, read the file, and write it to the stream.
    If you start noticing performance issues, then you can try doing some caching, but truth is your OS should be doing that for you.
    But, truth be told that's the only practical way to do it.
    Another solution would be to use JavaScriipt and XMLHttpRequest (i.e "AJAX") to load the file at the client side, and simply replace a tag with the results.
    That's also pretty trivial to write, any web site talking about AJAX should give you hint there.
    Of course, that won't work for folks who have JavaScript turned off, or some other incompatible browser, whereas the server side solution obviously works everywhere.

  • Dynamic String Substitution in Eclipse with JSP

    Hi folks,
    I'm wondering if it is possible to dynamically change token for ant that are present in my jsp with the dynamic string substitution in jsp inside tomcat. Right now, I'm loading the bootstrap with my runner and pointing to my application. In preference, I've put some token like @STATIC_URL@ that should replace by something else. But It seem that Tomcat goes directly to the source of the jsp and does'nt really care about the string substition of eclipse. Is there a way to do that?

    Hi there,
    Since this is more of an Ant or an Eclipse question it is better to post the question in those forums / mailing lists as people on those lists will be able to help you better:
    Here's the link to subscribe to the Ant User Mailing List, once you subscribe send a new e-mail to the list:
    http://ant.apache.org/mail.html
    Forum for Eclipse:
    http://www-128.ibm.com/developerworks/forums/dw_forum.jsp?cat=28&forum=472

  • Problem with jsp:element being ignored by my jspx

    Hello,
    !Please note that this is a JSP problem even though it is located in a jsf page!
    I have the following code:
    <jsp:element xmlns:jsp="http://java.sun.com/JSP/Page" name="link">
    <jsp:attribute name="href">${pageContext.request.contextPath}/css/xp/xp.css</jsp:attribute>
    <jsp:attribute name="rel">stylesheet</jsp:attribute>
    <jsp:attribute name="type">text/css</jsp:attribute>
    </jsp:element>which is not being evaluated. I just get nothing in lieu of the above code fragment.
    Here is part of my web.xml:
    <jsp-config>
            <jsp-property-group>
                <display-name>Expression Language</display-name>
                <url-pattern>*.jspx</url-pattern>
                <el-ignored>false</el-ignored>
                <scripting-invalid>false</scripting-invalid>
                <is-xml>true</is-xml>
            </jsp-property-group>
        </jsp-config>Here is the entirety of my jspx:
    <f:view xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:jsp="http://java.sun.com/JSP/Page"
            xmlns:ice="http://www.icesoft.com/icefaces/component">
         <jsp:directive.page isELIgnored="false"/>
        <ice:outputDeclaration
            doctypeRoot="HTML"
            doctypePublic="-//W3C//DTD XHTML 1.0 Strict//EN"
            doctypeSystem="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>     
        <html
         xmlns:jsp="http://java.sun.com/JSP/Page">
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                <title>JSP Page{9+1} - 05</title>
                <jsp:element xmlns:jsp="http://java.sun.com/JSP/Page" name="link">
                    <jsp:attribute name="href">${pageContext.request.contextPath}/css/xp/xp.css</jsp:attribute>
                    <jsp:attribute name="rel">stylesheet</jsp:attribute>
                    <jsp:attribute name="type">text/css</jsp:attribute>
                </jsp:element>
                <!--
                <link href="${pageContext.request.contextPath}/css/xp/xp.css" rel="stylesheet" type="text/css"/>
                <link href="${pageContext.request.contextPath}/css/console-style.css" rel="stylesheet" type="text/css"/>
                -->
            </head>
            <body>
                <ice:outputConnectionStatus/>
                <ice:form>
                    <ice:inputFile
                        progressListener="#{consoleInputFile.progress}"
                        actionListener="#{consoleInputFile.action}"/>
                    <ice:outputProgress
                        indeterminate="true"
                        value="#{consoleInputFile.percent}" />
                    <ice:messages
                        showDetail="true"
                        styleClass="consoleInputFileMessages"/>
                </ice:form>
            </body>
        </html>
    </f:view>Can anyone help please,
    Julien.

    That's a convoluted way to write out an image input field... Also, are you aware that by defining the variables in the <%! %> block you are making them class fields, and thus likely to be altered by any request at any time? In that case, it probably doesn't matter...
    anImage= "<INPUT TYPE=\"IMAGE\" NAME=\"WEB\" VALUE=\"GO\" SRC=\"" + imageDir + "go.gif\" WIDTH=\"26\" HEIGHT=\"24\" ALIGN=\"TOP\" BORDER=\"0\" ALT=\"GO\">";
    Anyway, I see nothing wrong with that. But I'd check the quotes and whatever in your code, cuz as I said, it's quite hard to see that the quotes are correct and all.

Maybe you are looking for

  • Changing the background of the pdf form in runtime.

    Dear All, I want to change the background of the pdf form in runtime. But I don't need to change the fillcolor. I want to change the background by using the pdf file. That means I want to switch the background of the pdf form on click events. I don't

  • Maximim Number of process and session can set in oracle 10g

    my os is 32 bit windows and ram size is 10gb and i am using AWE_WINDOW_MEMORY setting and now my sga is 6 gb.what would be Maximim Number of process and session can set in oracle 10g database

  • DW CS3 Errors

    I need some help and I'm hoping someone here may be able to... I just got CS3 (for Windows) and having been playing around with some of the programs. I briefly opened up Dreamweaver on Tuesday, but didn't do anything with it. Yesterday I wanted to tr

  • What are common error come in gap analysis

    Hi, Anyone can tell me, what common error occur in implementation and while how we can over come these error through gap analysis in sap hr.    Regards, Manker

  • ISync locking computer

    Searched for a feed back for iSync and could not find one, so I hope an Apple iSync guru reads this. Twice, since the latest update 10.5.5 and all security updates etc. have been installed, when iSync runs into a conflict my system freezes. Once whil