How to mention encoding in servlet.

Hi
How to mention encoding in servlet.
Regards
Arghya Banerjee

I suppose your question may refer to the setContentType method discussed here:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletResponse.html
If not, ask a more specific question.

Similar Messages

  • How do i run a servlet??????

    running servlets:i downloaded jsdk but how do i run a servlet? i got the error
    C:\WINDOWS\Desktop>javac HTTPGetServlet.java
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/M
    ain
    when i tried to run my servlet, please help
    thanks

    As mentioned in another post in the thread, servlets run from within a web server that has pre-loaded the jvm and serves web requests. Often they are called 'sevlet containers' as they act like a wrapper program for the actual vm. Tomcat is such a web server, quite a popular one for running servlets, and is considered the reference implementation for a sevlet/jsp server. you can read up on it at...
    http://jakarta.apache.org/tomcat/index.html
    To get you started, this is what i did to set up tomcat. Im using RedHat Linux at home, so this may differ to what you have to do initially.
    First, make sure you have at least the jsdk and jsdk ee installed and the appropiate JAVA_HOME and J2EE_HOME environment variables set.
    I am using the Apache web server to handle web page requests on my box. If the request is for a context containing a servlet or jsp file (context is a tomcat term for a particular location or path in the url) then apache passes the request to tomcat via a apache module and a special protocol. Tomcat then runs the .class file or .jsp file, returns the output to apache which then returns the output back to the browser. So initially you should set up and have the apache web server running.
    Next download and install the jserv or tomcat module for apache, which apache uses to communicate with tomcat via a special protocol, and the tomcat rpms from...
    http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.3/rpms/
    ...Im using 3.2.3 which works fine. you may try the later versions if you like.
    Install the tomcat rpms. They should dump a whole lot of stuff in a /var/tomcat directry, including some nice sample and admin apps. if you had downloaded and installed the tomcat-manuals rpm you can find lots of helpful information in the /usr/doc/tomcat-{your version here}/ directry. This is what you should probably read through now!
    Once that is done, its simply a matter of adding a reference in your httpd.conf file to the tomcat.conf file in the tomcat/conf dir (if you want to have complete control over the tomcat module and contexts) or tomcat-apache.conf (in the same directry) if youd like tomcat to handel its own configuration of apache. something like...
    include /var/tomcat/conf/tomcat.conf
    ...should do.
    then run tomcat start (in /usr/bin/) and apache and away you go. You should be able to point your browser to your.server.com/admin/ and get the tomcat admin tools. This allows you to add view and delete contexts to your server (say for separating different server-side applications). your.server.com/examples/ has some nice stuff as well.
    Hope this helps. I warn you im not an expert and haven't looked at this stuff for some time. I probably have something wrong so please, experts, if you see something stuffed up let us know.

  • How to call two different servlet-url in the same application

    Hi,
    I want to call, consecutively these methods in my application.
    response.sendRedirect(servlet-url1)
    reponse.sendRedirect(servlet-url2)
    but the second method dont answer,
    I think, the first method redirect s with response ,
    but how to call two different servlet ?
    thanks

    if you call the first redirect, the servlet is getting aborted, so you can redirect to the first servlet, working the stuff in it, and then in the second servlet you can redirect to the third servlet

  • How can I run a servlet with Sun Java System Application Server PE 8?

    I've created a package with a TestServlet.class inside, used the deploytool to create a WAR and deployed this using the autodeploy folder.
    The filestructure has been generated and I find the TestServlet.class in
    [installdir]\domains\domain1\applications\j2ee-modules\testProject\WEB-INF\classes\[packagefolderstructure]\TestServlet.class.
    The context root is working fine, but I have no clue how I can run the servlet directly via the URL.
    I've tried many things like
    http://localhost:8080/testProject/TestServlet
    http://localhost:8080/testProject/servlet/TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithpoints]TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithslashes]TestServlet
    etc etc
    Can somebody tell me please how to write URLs to deployed servlets? Or send me an example url and xml descriptor files?
    Thanks a lot in advance!

    in web.xml use servlet mapping
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/doit</url-pattern>
    </servlet-mapping>then use http://localhost:8080/testProject/doit

  • How do we run a servlet program in eclipse

    how do we run a servlet program in eclipse.

    Not at all, because servlets require a servlet container. Some Eclipse plugins (Lomboz etc.) do provide integration with those.

  • How can I test a Servlet?

    Hello!
    I want to test a small part of a servlet. That part connects to a database through a DataSource which is obtained in this manner:
    Context ctx = new InitialContext();
    ds = (DataSource) ctx.lookup(dsLookup);
    conn = ds.getConnection();Details about the servlet: runs on a WebSphere application server with db2 database. Runs on the local server in our intranet and I create a Java project in Eclipse with Create project from existing source: path to location on server.
    It's really annoying to start the browser, get to the page I'm interested, make the neccesary request and then see what happens in my code.
    What I've learned so far:
    I can't test it in a main function because I can't get the context. I tried setting the context's properties, still no go.
    I found this: http://www.ibm.com/developerworks/rational/library/08/0219_jadhav/
    but I got lost when it came to adding the resource reference to the project. How can one do that in Eclipse?
    Can anyone please, please, pretty please with sugar on top, explain to me how I can do this?
    Thank you very much for your time,
    Iulia

    Thank you for your prompt reply. I still have some questions:
    You say that configuration must go in the web.xml file. I don't have that file. In the tutorial example one application is a Java project the other is an application client and the other is an EAR of the application client. Neither of them have a web.xml file. So where do I set the resource?
    Do I have to have a WebSphere application server installed on my local machine?Where and how do I run the servlet?
    Thank you,
    Iulia

  • How to mention a  Relative path in a java file

    How to mention the relative path of the file in fileinputstream?
    The directory structure is as follows,Inside the **model** folder i have a java file called GetContents.java
    I need to refer the input.xls file inside the template folder in GetContents.java.file.
    I tried new FileInputStream("..\\..\\..\\template\\DevContentsTemplate.xls") cos the GetContents.class file will be inside webcontent\web-inf\classes\model\GetContents.class and I thought if i use the above relative path , it should refer webcontent\web-inf\template\input.xls
    But it throws a file not found exception.
    ContentValidation
    - src
    -action
    -model
              -bean
              -form
              -utils
    -WebContent
                   -WEB-INF
                        -classes
                        -action
                   -model
                             -bean
                             -form
                             -utils
                        -lib
                   -template
                             -input.xls
    Kindly help.
    Thanks.

    morshed_nsu wrote:
    if so then for one ../ you will reach classes folder. for another you will reach the folder containing src, classes, templates etc.
    So you do not need 3 escapes.I posted that same answer 7 hours before you did! What part of your answer is any additional help compared to mine? It's fine to give someone another answer, but there's not much point in giving the SAME answer 7 hours later. If it were a few seconds or a few minutes later, I would excuse you for having tried to post at the same time. But, 7 hours?! Please read the existing answers next time, not just the original post.

  • How To: Get encoding of a remote file

    How To: Get encoding of a remote file
    Java EE
    URL url = new URL ("http://www.someSite.com/myCsvFile.csv"); // comma separated
    InputStream is = url.openConnection().getInputStream();
    InputStreamReader reader = new InputStreamReader(is);
    System.out.println("reader.getEncoding(): " + reader.getEncoding());
    For both an ISO-8859-1 file and a UTF-8 file I get the following print out:
    reader.getEncoding(): Cp1252
    Could it have something to do with this warning during boot the .war?
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    If I use local files it prints ISO8859_1 for one of the files.

    All of that is because the HTTP server attaches a charset to every response. That's what you are seeing. The server may be using some logic to determine the actual encoding of the file it returns, or it may simply be using a hard-coded charset which may or may not be suitable for reading the file. The latter is unfortunately more likely.
    By the way if you receive an XML file over HTTP, and the HTTP charset differs from the encoding declared in the XML document, there's a rule which says the HTTP charset takes precedence. (I don't know where that rule is documented, but I have encountered that situation in real life -- the data came from a Google application -- and that rule was indeed the right thing to do.)
    If you're still under the impression that there's something which can look at a file and determine what encoding was used to produce it, let me tell you that there isn't. Sure, there's that XML prolog thing which works for XML files (if they weren't botched by the producer), but for text files in general there's no way to determine their encoding. Short of asking the person who created them, that is.

  • How to inject ejb in servlet

    hi all
    How to inject ejb in servlet ?
    please explain how to config my servlet and my paroject
    I have an ear file with two jar files
    Thanks in advance

    hi
    I have this error in my project
    I have an ear file ,two war file and three jar file in it
    and I did configuration
    but there was this error
    14:19:45,398 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[conference-servlet].[enterLet]] Allocate exception for servlet enterLet: javax.naming.NameNotFoundException: ITrmnlAuthenticationBL not bound
    @Remote
    public interface ITrmnlAuthenticationBL{
    @Stateless
    public class TrmnlAuthenticationBL implements ITrmnlAuthenticationBL{
    public class EnterLet extends HttpServlet {
         @EJB(mappedName = "ITrmnlAuthenticationBL")
         private ITrmnlAuthenticationBL trmnlMg;
    please explain my mistake

  • How to get absolute in servlet

    how to get absolute in servlet like c:\temp\apache group\tomcat4.1\test\abc.gif, thanks

    do sthing like:
    getServletContext().getRealPath("/abc.gif") in any servlet in 'test' to get the real path of abc.gif - The parameter should be relative to the current context

  • How can I let my servlet to process Chinese Character as an input?

    How can I let my servlet to process Chinese Character as an input to my simple database which is an Excel file. I have tried before and all my input values become question marks.
    Please give me some advise, thx!

    input chinese?����������
    that may result from the tomcat or other web server

  • How to insert the new Servlet Api Class files?

    Hi,
    I need to know how do I add the Servlet Api Class to my java directory
    after i download it from the net? Thanks for your help in advance!

    niceguyme,
    If you downloaded the J2EE 1.3.1 API and installed it to (for example) c:\j2ee131, then what you need to add to your class path is:
    c:\j2ee131\lib\j2ee.jar
    I also add c:\j2ee131\lib\ejb10deployment.jar to the classpath, but it is not necessary.
    there are several ways to add these to your classpath. It depends on what Operating System you are using. On windows 98 type OS, you can edit the autoexec.bat and add these directly to your already existing classpath. Windows NT,2000, and XP: you can add them to the system environment variables classpath. Hopefully you know how to do this on your machine. What I like to do on the windows machine is create a batch file that will start it from within a command prompt. I do this because there are times when I need to compile my code using different versions of the Java api. I am enclosing an example of one for J2se1.4.1 and j2ee1.3.1.
    contents of java141.bat
    @ECHO OFF
    ECHO JDK 1.4.1 and J2EE 1.3.1 are current versions
    set HOLD_CP = %CLASSPATH%
    set HOLD_PATH = %PATH%
    set CLASSPATH=.
    set CLASSPATH=%CLASSPATH%;e:\jdk14\jre\lib\rt.jar
    set CLASSPATH=%CLASSPATH%;e:\jdk14\lib\dt.jar
    set CLASSPATH=%CLASSPATH%;e:\jdk14\lib\tools.jar
    set CLASSPATH=%CLASSPATH%;e:\jdk14\lib\htmlconverter.jar
    rem **** J2EE STUFF ****
    set CLASSPATH=%CLASSPATH%;e:\j2ee131\lib\j2ee.jar
    set CLASSPATH=%CLASSPATH%;e:\j2ee131\lib\ejb10deployment.jar
    set CLASSPATH=%CLASSPATH%;%HOLD_CP%
    set PATH=e:\jdk14\bin
    set PATH=%PATH%;"C:\Program Files\TextPad 4"
    set PATH=%PATH%;c:\windows\command
    set PATH=%PATH%;%HOLD_PATH%I hope this helps.
    TJJ

  • How to invke the XSQL Servlet directly

    What I am really trying to achieve is the ability to forward an xml document to the XSQL servlet for further processing.
    How can I invoke the servlet rather than go via an xsql page and what parameters do I need to pass in order for it to work.
    I'm wondering out loud if the new filter capabilities of servlet 2.3 will achieve the desired effect.
    Any ideas?

    You can get the RequestDispatcher and call forward() on it
    to forward to an XSQL page. From another one of your posts
    it seems you might have already figured this out. :-)

  • How to attach a new servlet on my OC4J instance ?

    Hi there
    How to attach a new servlet on my OC4J instance ?
    Regards
    Den

    You can deploy your using JDeveloper:
    http://download.oracle.com/otndocs/tech/ias/portal/files/RG/OBE/deployToAppServer/lesson_Deployment.htm
    Or you can use the Application Server Control:
    http://download.oracle.com/docs/cd/B31017_01/core.1013/b28764/deploy_em003.htm
    Maurits

  • How to use a custom servlet in iFS?

    Hi,
    I'm creating a custom servlet to download files from iFS to local drive. My question is where should I put the servlet class file, and how do I invoke this servlet from a ifs jsp file?
    I'm running iFS 1.1.9, with JWS web server.
    Thanx.
    [email protected]

    Howdy:
    In the iFS Online Resources HTML whitepaper,
    there are several examples for creating and
    deploying servlets. See the section "Creating a Simple Content Management Application." Please check out: http://technet.oracle.com/products/ifs/htdocs/resources/index.htm
    Hope this helps,
    Dennis Dawson

Maybe you are looking for