Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Passing values from Servlet to JSP page

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hola
I am having problems to pass values from servlets to jsp pages. When I pass values from jsp to servlets all work fine! but inverse not work at all.
I am generating a html list (query from database) with a servlet, every item (or row) have an hiperlink, for example.


Then when the user choose one (to edit) it call a jsp page ( it have a html form) and would must to show the data choose filling the form.

The problem is that only pass one value!! and are 3 values.

Also I tried hidden input field, example:

I am using getParameter in my jsp page. example:

Someone know What happen?

Muchas Gracias
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you generating HTML in your servlet?!

In any case, without knowing what's actually happening, the values you're trying to put in the link, etc. it's really difficult to help.
 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

David Newton wrote:Why are you generating HTML in your servlet?!

In any case, without knowing what's actually happening, the values you're trying to put in the link, etc. it's really difficult to help.



Thanks David for write.
I had solved the problem. I eliminated the JSP page and create other servlet.
I used servlet because I need to connect to database. (more security I read) Also Is less work in my opinion. I mean if I make a JSp page then I must to do a servlet for send the data to database, but if I generate the html in my servlet I have all in one!

Gracias Anyway
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just because something works doesn't make it good, or a best practice. Valuable advice on advancing your knowledge is a shame to toss onto the rocks.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Generating HTML in a servlet is a Bad Idea, and was discredited a *long* time ago--it's why JSPs were invented.

Separation of concerns: it's important. You are creating application code that is difficult to maintain, enhance, and so on. Bad idea.
 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks both for the advices. You are reason!

I just was desperated for to work more fast.!

Thanks David for to be more explicit!

Muchas Gracias a Todos
 
    Bookmark Topic Watch Topic
  • New Topic