Where is the usage of serialization in a webapplication. Is it necessary that a form bean is serializable. In tomcat what is the usage of sessions.ser file..
121546
In my understanding of Servlet, the Servlet will be instantiated by the Container, its init() method will be called once, and the servlet will live like a singleton until the JVM shuts down.  I do not expect my servlet to be serialized, since it will be constructed new when the app server recovers or is starts up normally. The servlet should hold no session-specific members, so it does not make sense for it to be written to disk and re-instantiated. Is there a practical use for this?  My concerns are, that I put some non-serializable fields within there and then my app will mysteriously fail in a production environment where a different sort of session replication will take place.
54935
How would you go about finding out how much memory is being used by an object? I know it is possible to find out how much is used by a block of code, but not by an instantiated object (anytime during its life), which is what I want.
77755
&lt;servlet&gt;     &lt;servlet-name&gt;myservlet&lt;/servlet-name&gt;     &lt;servlet-class&gt;workflow.WDispatcher&lt;/servlet-class&gt;     &lt;load-on-startup&gt;2&lt;/load-on-startup&gt; &lt;/servlet&gt;  &lt;servlet-mapping&gt;     &lt;servlet-name&gt;myservlet&lt;/servlet-name&gt;     &lt;url-pattern&gt;*NEXTEVENT*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt;   Above is the snippet from Tomcat's web.xml. The URL pattern *NEXTEVENT* on start up throws     java.lang.IllegalArgumentException: Invalid &lt;url-pattern> in servlet mapping   It will be greatly appreciated if someone can hint at the error. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
118709
I need to insert/update/delete a variable number of records at a time from a webapp (so from javascript), are there reasons to choose the  over writing a custom Apex REST class to do this or vice versa?
61570
I would like to know what would be the best way to do unit testing of a servlet.   Testing internal methods is not a problem as long as they don't refer to the servlet context, but what about testing the doGet/doPost methods as well as the internal method that refer to the context or make use of session parameters?  Is there a way to do this simply using classical tools such as JUnit, or preferrably TestNG? Did I need to embed a tomcat server or something like that?
111998
Should Java Objects be reused as often as it can be reused ? Or should we reuse it only when they are "heavyweight", ie have OS resources associated with it ?  All old articles on the internet talk about object reuse and object pooling as much as possible, but I have read recent articles that say new Object() is highly optimized now ( 10 instructions ) and Object reuse is not as big a deal as it used to be.  What is the current best practice and how are you people doing it ?
51720
Is there a way to tell if an event handler has been added to an object?  I'm serializing a list of objects into/out of session state so we can use SQL based session state... When an object in the list has a property changed it needs to be flagged, which the event handler took care of properly before.  However now when the objects are deserialized it isn't getting the event handler.  In an fit of mild annoyance, I just added the event handler to the Get property that accesses the object.  It's getting called now which is great, except that it's getting called like 5 times so I think the handler just keeps getting added every time the object is accessed.  It's really safe enough to just ignore, but I'd rather make it that much cleaner by checking to see if the handler has already been added so I only do so once.  Is that possible?  EDIT: I don't necessarily have full control of what event handlers are added, so just checking for null isn't good enough.
21092
Is it possible to serialize and deserialize a class in C++?  I've been using Java for 3 years now, and serialization / deserialization is fairly trivial in that language. Does C++ have similar features? Are there native libraries that handle serialization?  An example would be helpful.
99297
I have a web service in C# and would like to have a nested inner class, that abstracts away the session collection, something like this:     public class Service : System.Web.Services.WebService {     [WebMethod]     public string Foo(string ticket)     {         SessionPool.getSession(ticket);     }      private class SessionPool      {         public static Session getSession(string ticket)         {             // this is what i want to do, but I can't access Context             return (Session)Context.Session[ticket];         }     } }    Is it possible to access the HTTP context of the WebService class via a nested class? If not, is there way I can store the reference to it?
79053
I feel like this should be really easy to do, but I can't find anything about it on the web. Is there a way, through either javascript or a java web servlet, to skip the subsequent authentication?  We are trying to use the REST Api in production, but the problem is, that each time you refresh the page in javascript, or delete the cookies in java, you have to login again to salesforce.  Is there some way to do an ajax call or the login in the background or whatever, so that you can have your application connecting to salesforce right away?
88953
Is there a good tool that checks the schema to determine custom fields and their use in triggers, page layouts, classes, etc? We have a couple objects that are getting close to the 500 max and it would be nice if there were a better way than having someone get a list of custom fields for an object manually and then searching every page layout, class, and trigger for use of each field.
33695
I have a Java bean like this:  class Person {   int age;   String name; }   I'd like to iterate over a collection of these beans in a JSP, showing each person in a HTML table row, and in the last row of the table I'd like to show the total of all the ages.  The code to generate the table rows will look something like this:  &lt;c:forEach var="person" items="${personList}"&gt;   &lt;tr&gt;&lt;td&gt;${person.name}&lt;td&gt;&lt;td&gt;${person.age}&lt;/td&gt;&lt;/tr&gt; &lt;/c:forEach&gt;   However, I'm struggling to find a way to calculate the age total that will be shown in the final row without resorting to scriptlet code, any suggestions?
55087
i am building a app which takes input from user and then search to a remote database(MySql).And then display the retrieved data on VisualForce page.One important note that my app will be distributable.  here is my controller class  public with sharing class Search  {    public String strTag {get;set;}   public String strlocation {get;set;}    public PageReference find() {              return null;   } }   Thanks in advance.  Updated  public with sharing class Search  {   public String strTag {get;set;} public String strlocation {get;set;}   public PageReference find() {             HttpRequest req = new HttpRequest();   HttpResponse res = new HttpResponse();   Http http = new Http();    req.setEndpoint('https://localhost/salesforce/');   req.setMethod('POST');     req.setCompressed(false);   req.setBody('key1=value1&amp;key2=value2');   req.setHeader('Content-Type', 'application/x-www-form-urlencoded');      try {     res = http.send(req);   } catch(System.CalloutException e) {     system.debug('Callout error: '+ e);   }   system.debug(res.getBody());      return null;  } }   I am getting below error now      error message System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = localhost/salesforce
100055
@RestResource(urlMapping='/v/restAPIKeyGeneration/*')  global with sharing class APIforKeyGeneration{       global class Account{     public String sname;     public String bp;  }      @HttpPost     global static String CallTo(Account[] account){     system.debug('rtrtr');     String Name;     String BillingCity;     for (Account i : account) {            Name = i.sname;            BillingCity = i.bp;     }     //String key = SourceMDMRestAPI.GenerateKey(account[0].Name);     return 'key' ;     }   }   public class SourceMDMRestAPI{     public static string GenerateKey(Account acc){//how can i cal this method in my webservice Account m=new Account(Name=acc.name);     return m.id; }
85933
I was writing a toString() for a class in Java the other day by manually writing out each element of the class to a String and it occurred to me that using reflection it might be possible to create a generic toString() method that could work on ALL classes. I.E. it would figure out the field names and values and send them out to a String.  Getting the field names is fairly simple, here is what a co-worker came up with:  public static List initFieldArray(String className) throws ClassNotFoundException {      Class c = Class.forName(className);     Field field[] = c.getFields();     List&lt;String&gt; classFields = new ArrayList(field.length);      for (int i = 0; i &lt; field.length; i++) {         String cf = field[i].toString();         classFields.add(cf.substring(cf.lastIndexOf(".") + 1));     }      return classFields; }   Using a factory I could reduce the performance overhead by storing the fields once, the first time the toString() is called. However finding the values could be a lot more expensive.  Due to the performance of reflection this may be more hypothetical then practical. But I am interested in the idea of reflection and how I can use it to improve my everyday programming.
108583
Does anyone know the major differences between the Java and .Net garbage collectors? A web search has not revealed much, and it was a question that came up in a test.
17145
I need to remove temp files on Tomcat startup, the pass to a folder which contains temp files is in applicationContext.xml.  Is there a way to run a method/class only on Tomcat startup?