QueryCAT Logo
Search 5,000,000+ questions and answers.

Frequently Asked Questions

How do I upload a file to my servlet or JSP?

On the client side, the client's browser must support form-based upload. Most modern browsers do, but there's no guarantee.For example, <FORM ENCTYPE='multipart/form-data' method='POST' action='/myservlet' > <INPUT TYPE='file' NAME='mptest' > <INPUT TYPE='submit' VALUE='upload' > </FORM> The input type "file" brings up a button for a file select box on the browser together with a text field that takes the file name once selected.

Which classloader should I use to load a resource file in Servlet/JSP packaged in my WAR module?

For example you have a properties file called debu.properties in WEB-INF/classes of your web module, you have to use the following code to load the properties file: InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/debu.properties"); See similar questions...

How do I access a database from my servlet or JSP?

JDBC allows you to write SQL queries as Java Strings, pass them to the database, and get back results that you can parse. To access database from your servlet, make sure JDBC driver for the database you are accessing is accessible to Web Server (Tomcat). For example, in Tomcat to access Oracle database through JDBC driver for Oracle, you need to place classes111.zip (renamed to classess111.jar) or classes12.jar in /WEB-INF/lib directory of the application or /common/lib directory of Tomcat. See similar questions...

How does a servlet communicate with a JSP page?

The following code snippet shows how a servlet instantiates a bean and initializes it with FORM data posted by a browser. The bean is then placed into the request, and the call is then forwarded to the JSP page, test.jsp, by means of a request dispatcher. This method can be used for any kind and any amount of data. public void doPost (HttpServletRequest request, HttpServletResponse response) { try { demo.FormBean f = new demo.FormBean(); String name = request.getParameter("name"); f. See similar questions...

Can I invoke a JSP error page from a servlet?

Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to create a request dispatcher for the JSP error page, and pass the exception object as a javax.servlet.jsp.jspException request attribute. In case or servlet, provide an anchor tag pointing to file that is to be downloaded. out.println("<a href=document1.doc>Document</a>"); See similar questions...

What's difference between Servlet/JSP session and EJB session?

jGuru: Servlets FAQ Home Page
From a logical point of view, a Servlet/JSP session is similar to an EJB session. Using a session, in fact, a client can connect to a server and maintain... See similar questions...

Can I use Sentry in a servlet or JSP application?

Sentry Spelling Checker Engine for Java - Frequently asked q...
Yes. You can use Sentry in any situation where Java can be used. Sentry Java SDK comes with a comprehensive set of servlet examples demonstrating a variety of ways of using the Sentry engine in a servlet to check spelling. See similar questions...

Can I view the Servlet code generated from a JSP after translation?

Yes. To do this, specify the "development=true" attribute in the global-web-application.xml configuration file. The generated servlet code will be saved in the persitstence directory for your application. The persistence directory can be found in the $ORACLE_J2EE_HOME/application-deployments/application directory, where application is the name of the application you are using. The name of the generated code will be your-jsp.jsp.java, where your-jsp. See similar questions...

Question: Why is document viewing implemented in a servlet instead of a JSP?

Verity K2 Troubleshooting FAQ
Answer: A JSP engine preserves white space, such as carriage returns in a JSP file, when it translates the JSP into a servlet. Thus, when a non-ASCII document format, e.g. Microsoft Word, is streamed from the K2 Viewing service to the browser, the added white space may prevent the browser from properly rendering the document. See similar questions...

How can I pass data retrieved from a database by a servlet to a JSP page?

One of the better approaches for passing data retrieved from a servlet to a JSP is to use the Model 2 architecture Basically, you need to first design a bean which can act as a wrapper for storing the resultset returned by the database query within the servlet. Once the bean has been instantiated and initialized by invoking its setter methods by the servlet, it can be placed within the request object and forwarded to a display JSP page as follows: com.foo.dbBean bean = new com.foo. See similar questions...

How do I prevent the output of my JSP or Servlet pages from being cached by the browser?

jGuru: How do I prevent the output of my JSP or Servlet page...
You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP page from being cached by the browser. Just execute the following scriptlet at the beginning of your JSP pages to prevent them from being cached at the browser. You need both the statements to take care of some of the older browser versions. lt;% response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 response. See similar questions...

Re[2]: How do I prevent the output of my JSP or Servlet pages from being cached by the browser?

jGuru: How do I prevent the output of my JSP or Servlet page...
Thanks B B for your reply. I tried this code. But it didn't work. Is there any other way to solve this problem. See similar questions...

Re[3]: How do I prevent the output of my JSP or Servlet pages from being cached by the browser?

jGuru: How do I prevent the output of my JSP or Servlet page...
It seems that only if you have submits on page with method post, it functioning the code below suplied as solution for the problem response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 response.setHeader("Pragma","no-cache"); //HTTP 1.0 response.setDateHeader ("Expires", 0); //prevents caching at the proxy server See similar questions...

Re[4]: How do I prevent the output of my JSP or Servlet pages from being cached by the browser?

jGuru: How do I prevent the output of my JSP or Servlet page...
I tried the same. But it doesn't work for me. Could you please give me little more details. what IE version you used. Mine is IE5.0 I appreciate your help. kind Regards, kennedy alagappan See similar questions...

Explore Other Topics

How do I redeem my AIR MILES® reward miles?
What is the electrical voltage?
How can I get rid of an infestation of worms in my waterfall?
Automatic Transmission Fluid (ATF) - What type of Transmission fluid can I use?
What food am I allowed to bring into Canada?
What is Relative Heat Gain?
How do I uninstall the QuickBooks Financial Software?
Where do I find my Shareholder Reference Number (SRN)?
b What are Batman's nicknames?
Can I get a copy of my dental records?
What's the difference between rock climbing and mountaineering?
Is there a risk of Large Offspring Syndrome (LOS) among animal clones?
More Questions >>

© Copyright 2007-2012 QueryCAT
About • Webmasters • Contact