Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Strange Behavior of JSP

 
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 new to jsp. I tried to read html form data into jsp page ... . I have taken two input fields of text and one submit button ... on clicking of submit jsp page shows first and last name. but problems arises when i run html file on server first time and submit it ... it won't work and field gets reseted ... but when i enter data again it works correctly. its strange thing that happened ... please help me with this

 
Ranch Hand
Posts: 136
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May i know why you are using that html form in out.println() line.. I think that is the prob it reloads your form once again so you are not getting it... try to remove that line and run it.. hope it will work.
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, if you are new to JSP, learn the good habits, that is no Java inside JSP, its discredited 10 years back.

As far as the problem, in your JSP, make type of submit to button, its should not be submit, also, there is no action, where do you expect the page to submit?
 
Paddy Joshi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

no Java inside JSP



can you please tell me why? can you give example regarding this i mean .... the code i written ...how to write in good jsp format... thnks in advance :-)
 
Sheriff
Posts: 67620
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
Read through this topic.
 
Greenhorn
Posts: 5
Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jsp pages with inline java codes is simply hard to maintain and debug. in your situation, having inline java codes is acceptable while learning jsp pages, that's how i started too. have you tried the suggestions of prasad and sabi? you should learn next about jsp el in order to replace inline java codes.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jowel Poquiz wrote:having inline java codes is acceptable while learning jsp pages


I would not accept that, you will not use that, so what's the point in wasting time to learn things which you don't use? It's better to invest these time in learning EL and JSTL..
 
Bear Bibeault
Sheriff
Posts: 67620
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
Indeed, it's like saying that using vacuum tubes is ok while learning how to design TVs. It's wasted effort and just creating bad habits.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic