Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing values from Servlet to JSP page  RSS feed

 
jhon masco
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
 
David Newton
Author
Rancher
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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Rancher
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!