wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP Display problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Display problem" Watch "JSP Display problem" New topic
Author

JSP Display problem

Deepak Chawla
Ranch Hand

Joined: Nov 19, 2003
Posts: 50
I Have this JPS code, i am trying to disply filesnames with link on it but i am getting these 2 complier error
1. illegal start of expression
2. ')' expected
for(int i =0;i<filesdisplay;i++)
{

out.write(<a href="/docs/projectname/eventtype/book1.xls"> Book1.xls </a> ;

}
plz help
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Next time you post code click the button that says disable smiles. It will make it easir to figure out your code.
I know nothing about JSP but shouldn't it be

Eric
Deepak Chawla
Ranch Hand

Joined: Nov 19, 2003
Posts: 50
I have a project which has some docs and i am trying to display docs on JSP Page, for displaying docs i am using this code
for(int i =0;i<filesdisplay;i++)
{

out.write(<a href="/docs/projectname/eventtype/filenames[i]"> filenames[i] </a> ;
}
I get 2 errors
1.illegal start of expression
2. ')' expected
But if try to write the out statement like this below
out.write("<a href='/docs/projectname/eventtype/filenames[i]'> filenames[i] </a>");
i get output as filenames[i], instead of a filename eg a.doc, b.ppt.
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
i think you need to reexamine your understanding of java syntax and grammar. what you want is this:

if you want to put a variable in a string you end that string ", use a concat operator + and then put the variable, then another concat + and you start a new string "


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
dee kal
Greenhorn

Joined: Oct 08, 2003
Posts: 10
Hi,
I am not sure how far this will work...just give it a try...
out.write("<a href='/docs/projectname/eventtype/filenames[i]'>" +
filenames[i] + "</a>");
Bye.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
dees code is not going to work.... since it does not take the array into account for the url string.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Why are you using out.write to emit HTML? That's inside out.
You should be using JSP to include Java in your HTML, not HTML in your Java.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: JSP Display problem
 
Similar Threads
File Browse in JSP on FireFox
How to read xlsx file from local java file
append xml using xslt
returning user defined objects
Help in jxls reader