// index.jsp
<form method="post" action="backend.jsp"> <input type="text" name="one" /> <input type="submit value="Submit" /> </form>
In backend.jsp what does request.getParameter(“one”); return?
request.getParameter("one").getClass().getName();
returns java.lang.String, so it must be a String right?
However I cannot do
String one = request.getParameter("one"); if (!"".equals(one)) {}
or
if (one != null) {}
This is obvious, because variable one does not return null. Is
if (one.length() > 0) {}
only way to go, or are there better solutions or a better approach? I am considering both solutions to be on jsp. Using a servlet (although jsp is a servlet) is a different use case in this scenario.
Related Posts:
- Spring Boot – Unable to resolve Whitelabel Error Page
- getting error HTTP Status 405 – HTTP method GET is not supported by this URL but not used `get` ever?
- What is the difference between response.sendRedirect() and request.getRequestDispatcher().forward(request,response)
- java.lang.NumberFormatException: null i
- org.apache.jasper.JasperException: Unable to compile class for JSP:
- WebServlet cannot be resolved to a type
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- What does this expression language ${pageContext.request.contextPath} exactly do in JSP EL?
- how to fix Cannot call sendRedirect() after the response has been committed?
- Response has aready been committed
- What is the difference between JSF, Servlet and JSP?
- Static Final Long serialVersionUID = 1L
- getOutputStream() has already been called for this response
- How to specify the default error page in web.xml?
- Problem with gif with transparent background
- Search for words with telephone numbers from 2-3-4 tree
- What is the reason behind “non-static method cannot be referenced from a static context”? [duplicate]
- Java string to date conversion
- Creating a “logical exclusive or” operator in Java
- Cannot make a static reference to the non-static method fxn(int) from the type Two [duplicate]
- How can I use pointers in Java?
- JavaFX – Exception in Application start method?
- Is there a stopwatch in Java?
- EOFException – how to handle?
- How to fix array index out of bounds error?
- How do I analyze a .mdmp file?
- Initialize List
- > in Java
- “No X11 DISPLAY variable” – what does it mean?
- en_US or en-US, which one should you use?
- javac : command not found
- Java says FileNotFoundException but file exists
- Why am I getting InputMismatchException?
- Java integer list
- How can I properly compare two Integers in Java?
- What is the difference between String.subString() and String.subSequence()
- Why Maven project is tied to J2SE-1.5 by default?
- Difference in System. exit(0) , System.exit(-1), System.exit(1 ) in Java
- Exception in thread “main” java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0)
- How to compare two double values in Java?
- Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0 error in Java
- How to override compareTo (Java)
- Why do I get an UnsupportedOperationException when trying to remove an element from a List?
- java.util.NoSuchElementException: No line found
- package does not exist error!
- Required: Variable Found: Value
- What does the colon (:) operator do?
- Shifting array to the right – homework
- How to get rid of Checkstyle message ‘File does not end with a newline.’
- Uri not Absolute exception getting while calling Restful Webservice
- Very Basic Java
- SQLRecoverableException: I/O Exception: Connection reset
- What exactly is a Maven Snapshot and why do we need it?
- How to check if my string is equal to null?
- what is Ljava.lang.String;@
- Missing method body, or declare abstract in Java
- java code is showing error. ( ‘;’,expected) [closed]
- How can I edit a .jar file?
- java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver Exception occurring. Why?
- JAVA_HOME should point to a JDK not a JRE
- This Activity already has an action bar supplied by the window decor?
- Convert hex string to int
- Orphaned Case Error in Java
- Proxy Error 502 : The proxy server received an invalid response from an upstream server
- Java double.MAX_VALUE?
- how to do a system pause in java for debugging?
- Immutable class?
- Is spring default scope singleton or not?
- Java Reflection – Object is not an instance of declaring class
- How to make a countdown timer in Java
- (Java) Tic-Tac-Toe game using 2 dimensional Array
- Incompatible types List of List and ArrayList of ArrayList
- Dice Rolling java program
- int cannot be converted to int []
- Joda DateTime to Timestamp conversion
- break statement in “if else” – java
- Get only part of an Array in Java?
- How to Get JSON Array Within JSON Object?
- What is a class constant?
- How to represent a fix number of repeats in regular expression?
- How to use a Do-while loop that continuously prompts a user?
- Java equivalent of unsigned long long?
- Getting “unixtime” in Java
- How do I break out of nested loops in Java?
- How do I convert this for loop into a while loop?
- Java switch statement: Constant expression required, but it IS constant
- Resolving File paths – ‘File not found’ error in Eclipse
- Simple Coin Toss using random class in Java. The do while loop doesn’t seem to generate random results
- Why I am getting DefaultHttpClient is deprecated?
- When should you use multithreading? And would multi threading be beneficial if the different threads execute mutually independent tasks?
- Append a single character to a string or char array in java?
- Preventing a Java class from being instantiated and inherited
- Collision Detection between two images in Java
- What does .pack() do?
- String is immutable. What exactly is the meaning?
- How do I autoindent in Netbeans?
- What is an attribute in Java?
- MessageBodyWriter not found for media type=application/json
- Conversion from Long to Double in Java
- Failed to find Java VM
- Java regex email