File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Syntax" Watch "Syntax" New topic


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

Joined: Jan 10, 2002
Posts: 63865

What happened when you tried it?

[Asking smart questions] [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
Try this code to send the parameters to the welcome file...
<a href="welcome.jsp?incity='"+ <%= city %> + "'& incountry='" +
<%= country % > + " '">
String s="welcome.jsp?incity='"+ city + "'& incountry='" +
country + " '";
<a href="<%= s %>" >
I hope the above one will work.

Afroz Ahmed(SCJP 1.4)

The value of an idea lies in the usage of it.
I agree. Here's the link:
subject: Syntax
It's not a secret anymore!