aspose file tools*
The moose likes Servlets and the fly likes Syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Syntax" Watch "Syntax" New topic
Author

Syntax

Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
I have a servlet which receives input from a form, processes the data and sends response to a JSP.
public class A extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException
{
String name =req.getParameter("name");
String city = req.getParameter("city");
String country = req.getParameter("country");
welcome.jsp? inname= name& incity=city & incountry=country;
}
}
I want to pass the 3 strings to a JSP welcome.jsp.
<%
String jspName = request.getParameter("inname");
String jspCity = request.getParameter("incity");
out.println("Welcome "+ jspName);
out.println("You live in "+ jspCity);
%>
Is the abpve correct in the servlet and jsp?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

What happened when you tried it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
Thanks. I got it.
Afroz Ahmed
Ranch Hand

Joined: Jan 18, 2004
Posts: 64
Hello,
Try this code to send the parameters to the welcome file...
<a href="welcome.jsp?incity='"+ <%= city %> + "'& incountry='" +
<%= country % > + " '">
or
String s="welcome.jsp?incity='"+ city + "'& incountry='" +
country + " '";
<a href="<%= s %>" >
I hope the above one will work.

Regards
Afroz Ahmed(SCJP 1.4)


The value of an idea lies in the usage of it.
 
wood burning stoves
 
subject: Syntax