File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills this week in the Jobs Discussion 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: 61756
    
  67

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP Display problem