Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Petr

Thread: Please correct this JSP code

  1. #1
    rajesh4851 is offline Member
    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

    Default Please correct this JSP code

    Hi Friends,
    I have created one JSP page which will do the following things:
    1) while opening, it will call UNIX shell script, this internally creates one zip file.
    2) Once this job is completed, it should display a hyper link. When the user click on this link it should give that zip file as pop-up.

    in my code , my hyper link is displaying like a normal text. ( 'click here' is not activated as hyper link displaying )


    Here is the code:

    Java Code:
    <%@page language="java" %>
    <%@page import="java.util.*" %>
    <html>
    <h1 style="font-family: Georgia; font-style:italic; font-size: 16px; color: #44BDE8;">Submitted your request to server </h1>
    <marquee behavior="scroll" direction="left" style="font-family: Arial; font-style:italic; font-size: 14px; color: #B7D1DA;"  >Processing ..!!               Processing ..!! </marquee>
    
    <head>
    
    <%
    
         String unixCommand = "sh /home/dev/raj/java/parse_all.ksh";
    
         Runtime rt = Runtime.getRuntime();
    
         Process p = rt.exec(unixCommand);
    
         p.waitFor();
    //String sLink  = http://272.17.34.204:7777/tools/ready_files.zip
      if (p.exitValue() == 0)
        {
          System.out.println("+");
    
    out.write("< a href=\"http://272.17.34.204:7777/tools/ready_files.zip\">Click Here</a>");
        }
        else
        {
          System.out.println("-");
        }
    
    %>
    
    </head>
    
    <body>
    
    </body>
    
    </html>
    Please help me to correct this code?

    Regards,
    Rajesh

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    618
    Rep Power
    4

    Default

    Hi. Maybe It has a mistake in this
    < a
    . Just delete a space.
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    rajesh4851 is offline Member
    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

    Default

    Thanks Petr.
    After doing the above change, i am getting error as follows:
    Error :
    [jsp src:line #:23]
    ')' expected. out.write("Click Here");

  4. #4
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    618
    Rep Power
    4

    Default

    Can you show your new variant )? I prefer to make it like that
    Java Code:
    <% String link = ""; %>
    <a href="<%=link%>">Text</a>
    Skype: petrarsentev
    http://TrackStudio.com

  5. #5
    rajesh4851 is offline Member
    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

    Default

    Hi Petr,
    I have tried this, but throwing lot of errors :(
    if u dont mind can u give me the complete code(error free)?

    Regards,
    Rajesh

  6. #6
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    618
    Rep Power
    4

    Default

    Oh. I noticed you located your code in head tags html. You must change it on body tags.
    Java Code:
    <%@page language="java" %>
    <%@page import="java.util.*" %>
    <html>
    <h1 style="font-family: Georgia; font-style:italic; font-size: 16px; color: #44BDE8;">Submitted your request to server </h1>
    <marquee behavior="scroll" direction="left" style="font-family: Arial; font-style:italic; font-size: 14px; color: #B7D1DA;"  >Processing ..!!               Processing ..!! </marquee>
    <head>
    </head>
    <%
         String unixCommand = "sh /home/dev/raj/java/parse_all.ksh";
         Runtime rt = Runtime.getRuntime();
         Process p = rt.exec(unixCommand);
         p.waitFor();
         String sLink  = http://272.17.34.204:7777/tools/ready_files.zip
         boolean result = p.exitValue()  == 0;
    %>
    <body>
    <a href="<%=result ? link : "#"%>">Click here</a>
    </body>
    </html>
    Last edited by Petr; 06-13-2011 at 12:17 PM.
    rajesh4851 likes this.
    Skype: petrarsentev
    http://TrackStudio.com

Similar Threads

  1. Please help - can't seem to correct this...
    By jmjbreezin in forum New To Java
    Replies: 7
    Last Post: 05-09-2011, 01:39 PM
  2. keyTyped is it correct
    By aizen92 in forum New To Java
    Replies: 18
    Last Post: 04-03-2011, 01:47 PM
  3. Replies: 10
    Last Post: 06-06-2010, 10:12 AM
  4. Are my comments correct?
    By twiggy62 in forum New To Java
    Replies: 2
    Last Post: 02-08-2010, 05:34 AM
  5. Replies: 1
    Last Post: 10-24-2009, 02:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •