Solved

href in jsp

Posted on 2004-04-25
16
611 Views
Last Modified: 2010-04-01
I want the filename to appear as a hyperlink on my page
Whats wrong with this statement:

out.println("<A HREF= '" + filename + "'");
0
Comment
Question by:pentiumnewbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 8
16 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10914829
you don't close the tag and also need to include the text link and end tag:
out.println("<A HREF= '" + filename + "'>click here</A>");
0
 

Author Comment

by:pentiumnewbie
ID: 10914844

With your code i get the same output as with mine, a hyperlink does'nt get displayed just code as it appears in your post.
0
 
LVL 92

Expert Comment

by:objects
ID: 10914865
it needs to be unside <% %>

<%
out.println("<A HREF= '" + filename + "'>click here</A>");
%>

or alternately you can use the following:

<A HREF="<%= filename %>">click here</A>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pentiumnewbie
ID: 10914903
This is what I have:
out.println("<A HREF=" '" + filename + "'">click here</A>");
        
And this is the error:
unclosed character literal
                                 out.println("click here");
0
 
LVL 92

Expert Comment

by:objects
ID: 10914908
try the code i posted above
0
 

Author Comment

by:pentiumnewbie
ID: 10914917

I have, but it didnt work
0
 
LVL 92

Expert Comment

by:objects
ID: 10914923
what was displayed?
0
 

Author Comment

by:pentiumnewbie
ID: 10914937
<%
out.println("<A HREF= '" + filename + "'>click here</A>");
%>

That just didnt work, the code was displayed

<A HREF="<%= filename %>">click here</A> threw this error:

illegal start of expression
                                 <%= filename



0
 
LVL 92

Expert Comment

by:objects
ID: 10914950
are you sure the page is getting processed as a jsp?
0
 

Author Comment

by:pentiumnewbie
ID: 10914956

yes, im using your file code from earlier and thats working perfect
0
 
LVL 92

Expert Comment

by:objects
ID: 10914985
what servlet container are you using?
0
 

Author Comment

by:pentiumnewbie
ID: 10914989

I dont even know what a servlet container is, this is my entire jsp:

<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="classfiles.*" %>
<%@ page import= "java.io.*" %>
<%@ page import= "java.net.*" %>
<%@ page import= "java.security.*" %>
<%@ page import= "java.util.Date" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.*" %>
<%@ page contentType="text/plain" %>


<%

String idnum = (String)session.getAttribute("idnum");
File f = new File("\\Pending");

File[] xmlFiles = f.listFiles();
boolean[] found = new boolean[xmlFiles.length];
for (int i=0; i<xmlFiles.length; i++)
{
        BufferedReader in = new BufferedReader(new FileReader(xmlFiles[i]));
        String str;
        while ((str = in.readLine()) != null) {
 String filename = xmlFiles[i].getName();
            if(str.indexOf("<Status>") > -1 && str.indexOf("1") > -1) {
                 
                
                           String status = str.substring(12, str.indexOf("</Status>"));
                           out.println(status);
                           out.println(filename);
                           out.println("<A HREF= "'" + filename + "'">click here</A>");
                           
                 found[i] = true;
   
                 break;
               
            }
        }
        in.close();
       
 
}

     
 %>
 
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 10915028
> <%@ page contentType="text/plain" %>

that line should be:

<%@ page contentType="text/html" %>
0
 

Author Comment

by:pentiumnewbie
ID: 10915046

I was thinking you were clutchin at straws with that last post but ya it worked, thanks alot :)
Whats the difference in the two lines?
0
 
LVL 92

Expert Comment

by:objects
ID: 10915058
the way u had it was saying the the returned page was plain text. thats why it wasn't getting interpreted as html.
0
 

Author Comment

by:pentiumnewbie
ID: 10915082

Thanks again
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
report generation frameworks 1 70
problem with  angularjs dropdwon search at object property (name) level 2 107
getting param value 7 59
build fail in maven project 11 197
Facebook has became the #1 social media platform. People share many funny videos there, yet you don't know how to download them? Now you can download Videos from Facebook in just 3 simple steps.
No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question