Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > HttpServletResponse sending Parameter to a JSP?

Reply
Thread Tools

HttpServletResponse sending Parameter to a JSP?

 
 
Duke
Guest
Posts: n/a
 
      05-06-2008
public class Portal extends HttpServlet{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
String name="Duke";
response.sendRedirect("show.jsp");
}
}

in the abow servlet Howto send the name variable as the parameter to
the show.jsp
Thank
DUKE
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      05-06-2008
Duke wrote:
> public class Portal extends HttpServlet{
> public void doGet(HttpServletRequest request,
> HttpServletResponse response)
> throws IOException, ServletException
> {
> response.setContentType("text/html");
> String name="Duke";
> response.sendRedirect("show.jsp");
> }
> }
>
> in the abow servlet Howto send the name variable as the parameter to
> the show.jsp


For redirect you will need to put in the URL.

If you used forward then you could have just stored in in
the request object.

Arne

 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      05-06-2008
Arne Vajhøj wrote:
> Duke wrote:
>> public class Portal extends HttpServlet{
>> public void doGet(HttpServletRequest request,
>> HttpServletResponse response)
>> throws IOException, ServletException
>> {
>> response.setContentType("text/html");
>> String name="Duke";
>> response.sendRedirect("show.jsp");
>> }
>> }
>>
>> in the abow servlet Howto send the name variable as the parameter to
>> the show.jsp

>
> For redirect you will need to put in the URL.
>
> If you used forward then you could have just stored in in
> the request object.


BTW, if your app supports login you should use response.encodeURL !

Arne
 
Reply With Quote
 
Duke
Guest
Posts: n/a
 
      05-06-2008
How to Send the parameter in case of forward?
Duke

 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      05-06-2008
Duke wrote:
> How to Send the parameter in case of forward?


request.setAttribute("name", "Duke");

before doing the forwards.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HttpServletResponse - does sendError terminate request stream? Tim Java 0 10-19-2004 03:57 PM
what is the relation between HTTPServletResponse setContentLength header and keep-alive Naresh Agarwal Java 1 05-29-2004 10:01 AM
Problem closing connection in HTTPServletResponse Naresh Agarwal Java 0 05-28-2004 08:47 AM
javax.servlet.http.HttpServletResponse.sendError() nullyfies any addHeader() Joerg Mueller-Tolk Java 2 12-03-2003 02:03 PM
HttpServletResponse.sendError Mike Landis Java 1 08-09-2003 12:53 AM



Advertisments