java - servlets checking params -


So I have a long long string string that can be ...

// Url = Z & amp; Surl = y & amp; Time = z & amp; Codec = a264 and acodec = MP3 and width = 400x100 or // url = z & amp; Surl = y & amp; Time = z & amp; Oplevel = w

is using the request I GetQueryString ("url") to check that a) QS and b) make sure that it does not have a tap, it is a big mistake of all statements Leading to the set. I was just thinking that there is a better way to do this.

Example .. (request.getParameter ("originalURL")! = Null & amp; Request.getParameter ("originalURL") equals (" ") And amp; and ................)

thanks guys

Sure, repeat the code to refact in the methods or use an existing structure.

The basic example of the refacted code:

  string field 1 = getField (request, "field 1", true); String Field 2 = getField (Request, "Field 2", True); String field 3 = getField (request, "field 3", incorrect); ... public stable string getField (HttpServletRequest request, string field name, boolean required) ValidatorException {string field = request. If (fieldValue == null || fieldValue.trim (). IsEmpty ()) {if (required) {New valuer throw throw ("field is required"); } And {fieldValue = null; // Make empty string blank so that you will not have trouble with later (""). }} Return field value; }  

You can definitely go one step further and adopt an existing MVC framework with verification (and conversion) capabilities, such as or


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -