Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 494573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:30:32+00:00 2026-05-13T05:30:32+00:00

So I have a big long query string that can either be … //url=z&surl=y&time=z&codec=a264&acodec=mp3&width=400×100

  • 0

So I have a big long query string that can either be …

//url=z&surl=y&time=z&codec=a264&acodec=mp3&width=400×100
or
//url=z&surl=y&time=z&optlevel=w

Im using request.getQueryString(“url”) to check if a) the qs is there and b) make sure its not null. This is all leading to a big messy set of if statements. I was just wondering if there is a better way to do it.

example..

if(request.getParameter("originalURL") != null &&
        request.getParameter("originalURL").equals("") && ................) 

Thanks guys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:30:32+00:00Added an answer on May 13, 2026 at 5:30 am

    Sure, just refactor the duplicated code into methods or make use of an existing framework.

    Basic kickoff example of refactored code:

    String field1 = getField(request, "field1", true);
    String field2 = getField(request, "field2", true);
    String field3 = getField(request, "field3", false);
    
    ...
    
    public static String getField(HttpServletRequest request, String fieldName, boolean required) throws ValidatorException {
        String fieldValue = request.getParameter(fieldName);
        if (fieldValue == null || fieldValue.trim().isEmpty()) {
            if (required) {
                throw new ValidatorException("Field is required");
            } else {
                fieldValue = null; // Make empty string null so that you don't need to hassle with equals("") afterwards.
            }
        }
        return fieldValue;
    }
    

    You can of course go a step further and adopt an existing MVC framework with validation (and conversion) capabilities, such as Sun JSF or Apache Struts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a big problem... i have this map HashMap<Long, String> examValues; It gets
I have some big (more than 3 fields) objects that can and should be
I'm writing mostly embedded code at work. We have a big long-term project that's
I have a set of lots of big long strings that I want to
I have a query which takes a long time and I want to optimize
I Have a Big Linq-to-entity Query and it's seem to be very long to
I have complicated query over very big table. Long story short, when I use
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
I have big system that make my system crash hard. When I boot up,
I have big URL list, which I have to download in parallel and check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.