Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use jstl's c:url tag  RSS feed

 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a situation where in i need to have a link beside all my rows displayed in a table inside a JSP.Now this particular link should be associated with a parameter preferably one of the column in the row displayed & should forward me to a servlet where in i can use the parameter and execute a query to retrive data from the database.can you please help me in coding by providing an example similar to this.
One of my friends told me i can use jstl's c:url tag.If yes please provide me with a proper example sir.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you have decided what the URL for the link needs to be, you can use the <c:url> to ensure that it is properly formatted. But you have to decide what data to use to construct the URL.
 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir can you explain how to use that with an example
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A better idea: you give it a shot and post the results here. And then we'll take it from there.
 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not able to get the correct code
I am displaying the student list in the jsp using c:forEach i need to have a hyper link to the column rollNo which takes me to the mentioned Servlet(BasicServlet)(or) should have a hyperlink "edit" in each row.(either of these mentioned will serve my purpose)
I have tried putting this piece of code in the <td></td> tag of the table
<c:forEach var="s" items="studentList">
<a href="<c:url value="/BasicServlet" >
<c:param name="rollNo" value="${s["rollNo"]}"/>
</c:url>>"edit </a>
studentList is my studentArray(named a in another servlet) which holds 10 student objects
request.setAttribute("studentList",a);
Is this piece of code written by me is right .please guide me with the right syntax.

[ September 26, 2008: Message edited by: ramanuja varun ]
[ September 29, 2008: Message edited by: ramanuja varun ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information. You can go back and change your post to add code tags by clicking the .

What is the resulting URL? How is it wrong? What are you expecting?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!