• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP Display problem

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 "
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dees code is not going to work.... since it does not take the array into account for the url string.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic