Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fow to forward to an action from jsp ?

 
Bibhudutta Pradhan
Ranch Hand
Posts: 31
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to forward to an action/jsp from jsp page like this.



How can i achieve this ?

Please help.
Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why? That's not an appropriate action for a JSP. Why are not such decisions being made in the action?
 
Bibhudutta Pradhan
Ranch Hand
Posts: 31
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Because I want to display data(from database) in the same page.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes no sense. If you forward, you're not on the "same page" any longer.
 
Bibhudutta Pradhan
Ranch Hand
Posts: 31
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. sir. Thanks for your reply.

Please help me how would i display data from a database in the same page on a click of a submit button(In struts2)

please help.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't use struts, so I can't help you with specifics. I just know that forward was not the right approach.
 
Bibhudutta Pradhan
Ranch Hand
Posts: 31
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also new to struts.

I used to display data from Database in the same page(in servlet/jsp) on click of a submit button like this :

info.jsp
............................................


1)The first time the info.jsp page is called info is null.Hence dont show info.
2)When the button is clicked servlet is called. the servlet gets the data from the database and then forward the data to the info.jsp page, setting info as attribute.
Now in the info.jsp info is not null. displaying the result.

I want to know is this the right approach to display data in the same page?
And now i want to do it in the same process in struts.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like what you need is Ajax.
 
Simranjeet Chawla
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bibhudutta Pradhan wrote:I want to forward to an action/jsp from jsp page like this.



How can i achieve this ?

Please help.
Thanks in advance.



You can try location.href=url on click of submit button
through javascript. In the "url" part you can mention the struts mapping url.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic