File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Method call with Parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Method call with Parameter" Watch "Method call with Parameter" New topic

Method call with Parameter

Mike Jenkins
Ranch Hand

Joined: Jul 23, 2006
Posts: 57
I have several RequestDispatcher references in a Servlet and would like to condense them using a method:

Current in my Servlet:

My attempt to use a method with 1 parameter gives me errors about invalid variables:

Please advise.
[ July 02, 2007: Message edited by: Mike Jenkins ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63874

gives me errors about invalid variables:

Details please.

[Asking smart questions] [About Bear] [Books by Bear]
arulk pillai
Ranch Hand

Joined: May 31, 2007
Posts: 3371
I think your req, resp variables are local and your method needs to take it as an argument. Your doPost() or doGet() method has the reference to req, resp. If that is not the case please provide more details like compile time or run time error and error details.

[] | [Java job hunting know how] | [Java resumes]
Sudhakar Kalk

Joined: Jul 02, 2007
Posts: 3
Please provide the error statements generated.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Welcome to JavaRanch!

We're pleased to have you here with us here on the ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. You can change it here

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

How is this method getting a reference to the request and response objects?
I agree. Here's the link:
subject: Method call with Parameter
It's not a secret anymore!