验证用户使用Java Script输入的SQL Query [英] Validating the SQL Query entered by user using Java Script

查看:102
本文介绍了验证用户使用Java Script输入的SQL Query的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的jsp中有一个textarea,用户将在其中输入select或insert或update或delete的sql查询。我必须验证输入的数据,并说明查询是否在语法上正确。例如,如果用户输入,

选择*从Tab ..:

这样,它必须抛出一条警告消息说,sql查询无效,因为用户输入..:在查询结束时。


我必须在javascript中执行此操作。

任何人都可以帮助我吗?


谢谢和问候

Anuradha

I have a textarea in my jsp, where in the user will enter a sql query of select or insert or update or delete.I have to validate that entered data and say whether the query is syntatically correct or not.For Example if User enters,
Select * from Tab..:
like this, it has to throw an alert message saying that, sql query is invalid as the user entered ..: at the end of the query.

I have to do this in javascript.
Can any one help me out?

Thanks&Regards
Anuradha

推荐答案

因为你必须在JavaScript中这样做,所以现在不是Java问题,现在是吗?另一方面,如果用户在浏览器中关闭脚本怎么办?
Since you have to do this in JavaScript, it is not a Java problem, now is it? On the other hand, what if the user turns off scripting in their browser?


这不是一项微不足道的任务!您将不得不解析输入并检查错误拼写,语法错误等等。也许你应该做一些基本的检查。
This is not a trivial task! You will have to parse the input and check for mis-spellings, syntax errors and lots more. Perhaps you should make a few basic checks instead.



如果用户在浏览器中关闭脚本怎么办?
what if the user turns off scripting in their browser?



您可以在客户端进行检查作为备份(并且只是为了遇到错误消息而保存到服务器的行程)。当然,应该始终在服务器端进行实际检查。

You can make checks on the client-side as a backup (and it saves a trip to the server just to be met with an error message). The real checking should always be made on the server-side, of course.


这篇关于验证用户使用Java Script输入的SQL Query的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆