• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

local variables acting like class variables in JServ??

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the problem is still unresolved if anyone can find the reason plz help
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand the if (j === ...) part...
Explain more clearly what you are doing in your JSP ?
Napa
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic