• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Simple JSP page

 
Raman Ghai
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have just started with JSP today and created the first JSP page.
However , it is not providing the output as expected . Here's the source code


Please help me find the errors ..
Any other resources /information regarding JSP will be appreciated. thanks
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all stop writing java code inside jsp, its a very old practice.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey is correct. If you are just starting out on JSP, it's important to use modern techniques and develop good habits right at the start.

The use of Java code in scriptlets in a JSP has been discredited since 2002 (10 years ago! ) and is no longer acceptable. You should find a tutorial or other learning materials that emphasize the JSTL (JSP Standard Tag Library) and the EL (Expression Language).

I also recommend that JSP novices read the following articles:
  • The Secret Life of JSPs
  • The Front Man

  •  
    Raman Ghai
    Ranch Hand
    Posts: 51
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    ok..I understand that use of java code inside JSP has been deprecated ..I will take care in future ..Thanks for replying.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64717
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    So why not try posting your example code using modern JSTL and EL?

    And, after you used the JSTL and EL, does the page still exhibit the same problems that you are trying to solve?

    (I also recommend learning how to format and indent HTML properly.)
     
    Raman Ghai
    Ranch Hand
    Posts: 51
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I have no idea about JSTL and EL . Actually, I am a beginner on web technologies. So , it will take some time to get familiar with all this stuff.
    As far as HTML indenting is concerned , I will learn that too. Thanks
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64717
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What tutorial are you using that led you up to the point that you were able to write the code of your initial post? If it does not talk about JSTL and EL, then it is either very old and antiquated, or just a bad one.

    Any (good) modern tutorial on JSP will cover JSTL and EL.
     
    dineshiop kumar
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    i would like to recommend Head First JSP and learn it is easy way of learning jsp and effective
     
    Raman Ghai
    Ranch Hand
    Posts: 51
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bear Bibeault wrote:What tutorial are you using that led you up to the point that you were able to write the code of your initial post? If it does not talk about JSTL and EL, then it is either very old and antiquated, or just a bad one.

    Any (good) modern tutorial on JSP will cover JSTL and EL.

    I read that code from an e-book on Java Servlets(don't remember the name). It has not mentioned a thing about JSTL or EL in the beginning . Do you know any good books/e-books to start with ?
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64717
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The JavaRanch Bunkhouse is a great place to start to find books on such subjects. There you will find not only lists of books on various Java and web-related subjects, but expert reviews of these books. Take a look!

    Be aware that even modern books on JSP are likely to cover scriptlets -- knowledge of them may be needed to work on legacy web apps. But scriptlets should never be used in new pages.
     
    Arun Giridharan
    Ranch Hand
    Posts: 290
    Debian Fedora Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bear is right as always !! EL and JSTL is indeed FUN ! and used alot.
     
    Stefan Evans
    Bartender
    Posts: 1691
    10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ignoring the scriptlet side of things, I can't see anything else wrong with the example as is.
    No errors. What was the problem with it?

    Rewriting as JSTL is fairly simple though:

     
    Raman Ghai
    Ranch Hand
    Posts: 51
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Now the same code worked right on retrying using Netbeans IDE. Atleast I got to learn about some things ..Thanks guys for replying
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic