This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP Calling a servlet with parameter using href Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Calling a servlet with parameter using href" Watch "JSP Calling a servlet with parameter using href" New topic
Author

JSP Calling a servlet with parameter using href

Danny Baquilod
Greenhorn

Joined: Jun 26, 2011
Posts: 14

Hello, a have a problem calling a servlet from JSP.. here's my code

I'm calling a servlet name SvPHeader and I'm getting an error HTTP Status 404 - /SvPHeader when clicking "Edit" . Thanks in advance for your assistance

<TR>
<TD><%=rs.getString(1)%></TD>
<TD><%=rs.getString(2)%></TD>
<TD><%=rs.getString(3)%></TD>
<TD><%=rs.getString(4)%></TD>
<td><a href="http://localhost:8081/SvPHeader?pono=<%=rs.getString(2)%>" />Edit</td>

</TR>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

Java code and a result set in a JSP?

In an case, you should be looking at the HTML thtas generated rather than thesaource code.

But, your href is missing the contex path,and why does it have the host part of the URL? Is it in a separate web app?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Danny Baquilod
Greenhorn

Joined: Jun 26, 2011
Posts: 14
Bear Bibeault wrote:Java code and a result set in a JSP?

In an case, you should be looking at the HTML thtas generated rather than thesaource code.

But, your href is missing the contex path,and why does it have the host part of the URL? Is it in a separate web app?


Hi, I understand your "shock" reaction. I will change that later on. I'm just starting to move to MVC Thanks for calling my attendtion.

Here is my problem again:
My code is in JSP displaying a table(list of data) and would like to call a servlet and passing a parameter. I tried to google it but I got some answer that I have to include the URL but I'm not sure if I'm getting it right.

In a servlet I would be calling a bean class to set the data and forward to JSP to display it for editing.

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

What is the servlet mapping? If you use the <c:url> tag to format the URL using the mapping, it will automatically prepend the context path.

Otherwise, you need to build it up yourself in the format: /context-path/servlet-mapping

To get the context path using the EL: ${pageContext.request.contextPath}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP Calling a servlet with parameter using href