sudhir nim

Ranch Hand
+ Follow
since Aug 29, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by sudhir nim

Set the lgnid as request attribute in first JSP



In second JSP, you can access the request attribute using scriptlet, expression or JSP el.

Note: you need to use request attributes and not request parameters, they both are different.
13 years ago
JSP
- You can use "target " attribute of anchor and specify "_blank" as value to open the URL in new window. OR
- Use a javascript dialog box, there are lot's of around, try jquery modal dialog box.
13 years ago
JSP
In simple words: you can not, Javascript and servlets are totally different, one runs in browser and one on server.
You can use ajax or a simple GET/POST to send the variable value to server.
13 years ago
I think there's no way to get the client IP who is behind the proxy, not atleast in servlet API
13 years ago
JSP
You can create a helper class that will write the name and age parameters to given file.

For example
- Create a helper class that will have a method like writeToFile which takes three parameters (path, name, age)
- The method would open a file using given path, and append the name and age
- The servlet will use the helper to write the name and age information to the file.

For How to get the real path of a file, See ServletContext.getRealPath

See how to process the html form submission

- Do not write the IO code directly in servlet
- You may want to consider thread safety issues

And, why do you need to write it to a file ? If you want to just store it and retrieve later , a database is better at storing and querying then a simple text file.
13 years ago
Deploy your application to your machine, give your IP to your friends and ask them to access it using urls like http://xx.xx.xx.xx/app-name
You need a static P to let your friends access it over internet, or if you are on a local network, you can give your IP to your fiends who are on the same network.
13 years ago
JSP
You can not have two servlets mapped to same URL pattern. If you define your URL mapping this way, the result can be unpredictable. In any situation, both of your servlets will never be executed for same request/url-pattern, So avoid it.
13 years ago
You are not forced to declare any of doGet or doPost methods. That depends on how you are planning to use that servlet.
If you want your servlets to support HTTP Get method (eg when user directly hit the url in browser) implement doGet() or you will get that error.
If you want your servlet to just support http post mehod (eg a form with method=post), you don't need doGet and you can declare just doPost method.


i hope you get the point :-

- If no doGet() - trying to access the servlet using http get method would result in 405
- if no doPost() - HTTP post request would result in 405
13 years ago
The rule for equals() and has code is

If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
But the reverse is not necessary, that is If two objects has same has code that doesnt mean they both must be equal


If i am not missing some thing here. the Option C would satisfy this condition, Option D would fail when the vaues of rate and balance are interchanged for two objects.
Once you have data available in servlet, you can set it as request attributes, and then forward request to JSP, in JSP you can access these data from request attributes using JSP EL and jstl, and generate html markup
13 years ago
Here's some thoughts on refactoring your code,

- Remove scriptlets from JSP, there should be no java code in JSP, use JSP absolutely for presentation purpose. it just displays data provided by controller
- Move data access code to data access objects - DAO
- Move business logic related code to services
- No data access/business logic code in your servlets/controller
- You controller (or servlet if you are not using any framework) uses services and DAOs and provided data to view (JSP) for display
- Have your domain model and entities instead of writing database table oriented code.



13 years ago
JSP
And sending mails through a JSP is a bad practice, You should be doing this in your controller/servlet probably.
13 years ago
JSP