Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

pass variableA which is declared method A in method B

Avatar of lilyyan
lilyyan asked on
17 Comments1 Solution249 ViewsLast Modified:
hello, every1,

got a question about variable access in a java class

public class myclassA {

publicv doPost(HttpServletRequest request, HttpServletResponse response){

String firstName ="", midName="", lastName="", title="", fileName="";

boolean isMultipart = DiskFileUpload.isMultipartContent(request);

if (isMultipart ){

getFormdata(firstName, midName, lastName, title, fileName);


} // end of doPost

public void getFormdata(String firstName, String midName, String lastName, String title, String fileName){

                    // Create a factory for disk-based file items
                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    //maximum size that will be stored in memory
                    // Create a new file upload handler
                   ServletFileUpload upload = new ServletFileUpload(factory);

try {
List fileItems = upload.parseRequest(request);



}// end of myclassA

my questions are:

q1. in the doPost method, it get the http request and servlet
when i call getFormdata() in doPost(), do i need pass the request or respose reference to getFormdata()

q2: when i pass firstName , midName ... to getFormdata(), the values of firstName and midName have been changed in getFormdata().

will the values of firstName and midName in doPost() are automatically chenged as well?

Avatar of Mick Barry
Mick BarryFlag of Australia imageJava Developer
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answers