Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

local variables acting like class variables in JServ??

 
Manoj Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am confronted with a strange problem. I have defined some variables in the doPost method,and initialised them by request.getParameter() . I am modifying their value in the code , but the next time the doPost method is executed , I get the modified values??I am actually calling the doGet method first and the the doPost. I am not writing the modified value or saving it in the instance variables or the static variles , I think it is absolutly crazy
HERE IS THE SERVLET TAG (I am using JServ)
<servlet code="com.MindShaper.ClassTeacher.Apps.HigherEd.IIFT.Utility.QueryResultAsLink" codebase="/servlets">
<param name="table" value="INSTITUTE_CHAPTERS,IIFT_CHAPTERS">
<param name="where" value="INSTITUTE_CHAPTERS.icourse_id,icourse_id">
</servlet>
HERE IS THE CODE

public class QueryResultAsLink extends HttpServlet
{
static MSConnectionBroker connBroker;
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
doPost(req,res);
}

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{

PrintWriter out = res.getWriter();
res.setContentType("text/html");

try{

String[] where=req.getParameterValues("where");
String[] whereVal=null;
if (where!=null)
{
whereVal=new String[where.length];
for (int i=0;i<where.length;i++)
{
int j=where[i].indexOf(",");
if(j==-1)
{
whereVal[i]=req.getParameter(where[i]);
}
else
{
String where2=where[i].substring(j+1,where[i].length());
where[i]=where11;
//IF I COMMENT OUT ABOVE LINE, I GET THE ACTUAL VALUES ELSE I GET THE MODIFIED VALUES
whereVal[i]=req.getParameter(where2);
}
}
}
else where=new String[0];
}
catch(Exception e)
{
Log.log(e);

}

}

GOD BLESS THOSE WHO HELP MEE!!!
}
[ February 01, 2002: Message edited by: manoj pandey ]
 
Manoj Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is still unresolved if anyone can find the reason plz help
 
Napa Sreedhar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are quite some problems in understanding your code.
You use req.getParameter(....) on form variables
i(j==-1) // where did you get this j
{
whereVal[i]=req.getParameter(where[i]); // where[] contains values and no form variables
}
else
{
String where2=where[i].substring(j+1,where[i].length());
where[i]=where11;
//IF I COMMENT OUT ABOVE LINE, I GET THE ACTUAL VALUES ELSE I GET THE MODIFIED VALUES
whereVal[i]=req.getParameter(where2); // why are you using again req.getParameter ? This is not at all needed.

Please check your code ...
Napa
 
Napa Sreedhar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand the if (j === ...) part...
Explain more clearly what you are doing in your JSP ?
Napa
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic