This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes invoking an action from a JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "invoking an action from a JSP page" Watch "invoking an action from a JSP page" New topic
Author

invoking an action from a JSP page

Gaurav Pawar
Ranch Hand

Joined: Sep 12, 2006
Posts: 37
Hi all,
I have a struts application. To invoke this app i type a url manually into the browser.

The URLs look like these
http://localhost:8080/MyAction.do?id=1&q=how are you?&indx=3 (enter data)
http://localhost:8080/MyAction.do?id=2&indx=3 (retieve data)

Till now to check if the application is running fine i used to directly type in the URL in the browser.

Now i wish to write a JSP page for the same.

The issue is--> i will be having a jsp page with textfields for 'q' and 'indx'
but if i click button1 the value for 'id' should be 1 and button2 should result in 'id=2'

Can someone please help me/suggest the exact approach to this? How do i generate these urls so that they are fired from the browser and then invoke the action?.....(jsp example?)

This will be my first complete struts application if i succeed

Thanks in advance.
Regards,
Gaurav.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Sounds like a little touch of JavaScript to format the URLs on the button clicks is all that you need.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gaurav Pawar
Ranch Hand

Joined: Sep 12, 2006
Posts: 37
Can you suggest any good references/examples??
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
Originally posted by gkpawar Pawar:
Can you suggest any good references/examples??


Have both your buttons call a javascript function passing the id as param, like this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: invoking an action from a JSP page
 
Similar Threads
URL changing problem
Having problem with prepared statement
multiple URL mapping for one web app
integration of struts- jsf Problem related t url
Iterating Over Query Parameters