The Artima Developer Community
Sponsored Link

Java Answers Forum
Hidden Fields in Servlets

4 replies on 1 page. Most recent reply: Oct 29, 2003 8:43 AM by Robert J. Saulnier

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Dar

Posts: 9
Nickname: dar
Registered: Oct, 2003

Hidden Fields in Servlets Posted: Oct 28, 2003 7:40 AM
Reply to this message Reply
Advertisement
I have a HTML hidden variable that I'm trying to send from a Servlet to a JSP page. The hidden variable has a SQL Database query assigned to it as its value. However, in my JSP page, when I read the value of the hidden variable, I can't read the entire value. It only reads the SELECT, FROM, but not the WHERE part of the clause. Below is my syntax:

-------Hidden variable syntax in my Servlet----------------
out.println("<form name='printForm' action='../jsp/printdwgSearchQuery.jsp' method='post' target ='_Top'>");

out.println("<input type ='hidden' name ='queryVal' value ='" + SQLQuery + "'></form>");

out.println("</body></html>");

--------My SQL Database query-----------------------------
SQLQuery = "Select dwgID, PMDwgNum, projectNum, Title, Type From AJM.Drawing " + whereclause;

NOTE: The 'whereclause variable in my query is put together in another part of the code.

--------Reading the value of the hidden variable in my JSP page------------------------------

hiddenVal = request.getParameter("queryVal");

-------Output when I run the query-------------------------

Select dwgID, PMDwgNum, projectNum, Title, Type From AJM.Drawing where UPPER(Title) LIKE UPPER(

As you can see, the query is read except the WHERE clause parameter.

Any ideas?



Thanks


Joe Parks

Posts: 107
Nickname: joeparks
Registered: Aug, 2003

Re: Hidden Fields in Servlets Posted: Oct 28, 2003 8:26 AM
Reply to this message Reply
Can you print the value of the whereclause to the console? Is it split up over multiple lines? What does it look like in the source of the generated page?

Dar

Posts: 9
Nickname: dar
Registered: Oct, 2003

Re: Hidden Fields in Servlets Posted: Oct 28, 2003 12:37 PM
Reply to this message Reply
The variabel 'whereclause' does have a value. Here's the jist of what this part of my application is:

There's a search engine where a user can select multiple search criterias when searcing for drawings. In my Servlet, I retrieve the parameters the user enters for their criteira, and assign them to the 'whereclause' variable. So for example, if the user enters A24 as the drawing number to search by, then the 'whereclause' variable has the value 'WHERE UPPER(dwgNum)(my database column name) = UPPER('a24').

Then, I append the 'whereclause' variable to the SQLQuery variable as follows:

SQLQuery = "Select dwgID, PMDwgNum, projectNum, Title, Type From AJM.Drawing " + whereclause;

I know this works because I output the results of the query for the user to see. That part works. But I also provide them a 'PRINT' button that when they click it, I send the SQLQuery variable to another JSP page, run the same query so the output is in a report format. That's where the problem is because the SQLQuery variable is sent through an HTML hidden tag and the jsp page retrieving the hidden variable cannot seem to read the WHERECLAUSE part of the SQLQuery.

Dave Hinton

Posts: 42
Nickname: catbells
Registered: Oct, 2003

Re: Hidden Fields in Servlets Posted: Oct 28, 2003 1:02 PM
Reply to this message Reply
Your WHERE clause contains quotes... are you escaping them (into &amp;quot; or &amp;apos;) or is the browser interpreting them as ending the hidden value?

Robert J. Saulnier

Posts: 2
Nickname: wwwizard
Registered: Oct, 2003

Re: Hidden Fields in Servlets Posted: Oct 29, 2003 8:43 AM
Reply to this message Reply
IMO, your SELECT statement is not something you want to put in a hidden field. I would put it in the Session. That way, clients won't see what tables you have in your database, and more importantly, change the post info and send a new query to your database to query all the records in your table.

Bob

Flat View: This topic has 4 replies on 1 page
Topic: XMLBeans or JDOM, JAXP Previous Topic   Next Topic Topic: How to install com.bruceeckel.simpletest

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use