Ankit Dan

Ranch Hand
+ Follow
since Aug 31, 2012
Ankit likes ...
Eclipse IDE Java MyEclipse IDE
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
6
Received in last 30 days
0
Total given
15
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Ankit Dan

This ll clear your doubts. java.lang.NullPointerException

Hope this helps!
Ankit
4 years ago

By default the Integer reference x will be assigned null value that is why your program is throwing NullPointerException.

Hope this helps!!
Ankit
4 years ago
Java itself has no concept of composition—a class or attribute can’t be marked as a component or composition. The only difference is the object identifier: A component has no identity, hence the persistent component class requires no identifier property or identifier mapping.
Hibernate uses the term component for a user-defined class that is persisted to the same table as the owning entity, that is not the case in one-to-one mapping

Hope this helps
Ankit
Try this:

Right-click on the Tomcat server (under the Eclipse Servers perspective)
Select Open - it should open up the xml editor
Look for the Timeouts section and increase the value to > 45s



hope this helps!!
4 years ago
From docs

public class StringIndexOutOfBoundsException extends IndexOutOfBoundsException

Thrown by String methods to indicate that an index is either negative or greater than the size of the string. For some methods such as the charAt method, this exception also is thrown when the index is equal to the size of the string.



But in your case there is no such condition and it is fine if you have a zero length string. Using s.charAt(2) will definitely throw a StringIndexOutOfBoundsException

Hope this helps

Ankit
4 years ago
Which exception you were expecting?
4 years ago
you can use something like this

4 years ago
Check your jar files, if you have included jsp-api-2.0.jar in your jars remove it and then try it, i had encountered such problems too earlier
this problem occurs because of mixture of jar files

Hope this helps

Ankit
4 years ago
it is a very general problem. and it can be dealt by redirecting the request instead of forwarding it.

See, the flow of your request would be
1. request come to servlet in any specific mode.
2. you do the specific business logic.
3. you forward request to any jsp.
right.

Now you have to make change in flow.
in third step you don't forward request, instead you redirect request. (use sendRedirect method (or an equivalent in struts framework).

Now what will happen in this case is. your work is getting done in two request. first request do the business logic. and second request displays confirmation message.

When you refresh page, then only last request will be repeated, i.e. only confirmation message, not the business logic.

But do it only for those request there is any harm due to refresh (as you told here).

Hope this helps


Ankit
4 years ago
If you have a complex object in your list
like a user dto and it contains firstname and last name

you can use the listKey and listValue attribute of struts select tag
listKey is the value that ll be submitted and listValue is the attribute that ll be displayed on the list

for example my userList contains the user dto objects
and the user dto has the fields firstName and lastName and i want two selects one for first name and another for last name
so for first name:

for last name


hope this helps

Ankit
4 years ago
woah woah!!
to get struts running you have to use struts tags, you have used HTML tags

here is what it ll look like after you ll use struts tag




hope this helps

Ankit
4 years ago
the problem is struts tags are loaded first, quite astonished to see javascript code use jquery, much more easier
try $("#idofgrid").jqGrid('getGridParam', ....); to get grid params just a hint

Hope this helps
4 years ago
well instead of simple HTML tags try to use struts tag, for textbox and submit minimal difference in their attributes
like
or

Check out this link
Struts 2 Tags

hope this helps
4 years ago
The System.out.println() on a variable will never work inside something that will never be executed as the entry point is always main so System.out.println() should either be inside main() method or some other method that ll be called by main in the program runtime

Hope this helps


Ankit
4 years ago
Which method is called depends solely on the request type that is stored in the HttpRequest instance. It works the same for all containers. Unless you specifically modify the request instances, all subsequent servlets will be called with the same method. So GET requests will never invoke doPost() unless you tamper with the request type..

Hope this helps

Ankit
4 years ago