This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of DevSecOps Adventures: A Game-Changing Approach with Chocolate, LEGO, and Coaching Games and have Dana Pylayeva on-line!
See this thread for details.
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

SQL:PARAM tag (type not found error)

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have used the following code snippet but am getting errors.

Here is the code:



The error I am getting is :

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException:
INSERT INTO positions(id,job_title) VALUES (?,?)


: Type is not supported.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ugh--I hope you're just prototyping and not using the sql tags for anything real.

Are both params filled when the page is run?
 
namrata suri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

No the code I posted is the actual code and in fact is from an eclipse tutorial. Even before the form comes up, I get an error. If i replace the ? with actual values, the code runs just fine, so i am guessing something is wrong with the sql:update - sql:param part. Unable to figure that out though.

Thank You.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The part where the parameters are filled in or not, like I asked.
 
namrata suri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not able to figure that out because the moment I run the jsp, i get the error messages.

As in, the form should come first asking me to enter the values... but instead I directly get the error without getting a chance to fill the form.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you have a misunderstanding about how JSPs work: the server side stuff (custom tags, scriptlets, etc.) are run in their entirety on the server side. *Then* the rendered HTML is returned back to the client (the browser). Your SQL tags are executing with no parameter values unless you pass parameters in.

Once you fill out the form and submit back to the JSP (a bad practice, by the way) there are parameters so the tags won't fail.
 
namrata suri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for clearing my doubts to some extent. I am new to jsp's and was following this tutorial.

http://www.eclipse.org/articles/article.php?file=Article-EclipseDbWebapps/index.html

Here, he has written a similar code and the parameters seem to be getting passed. I think its better if I write the sql code in another jsp.



 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code on that page does a check to see if there are parameters before attempting to use non-existent parameters.

IMO this is the worst kind of tutorial: it provides a working example, but is full of worst practices without any references to how to actually do things right.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Uggh! I just looked, and I agree with David.

I'd use that tutorial as a good example of what not to do!
 
namrata suri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
Thanks for the answers. I found my way around the problem. Did not realize the tutorial was that bad.

I guess the thread can be closed now.
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic