Basic servlet doubt

Hi,
I am very much new to servlet technology. I have written a servlet which will display a form containing a link. When the user clicks on the link i want to him to test.html which is stored in my home directory. I don't want to store test.html in my web applications directory. If i keep the file in my web application foler, its working. Here is my code :
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CustomTagTest extends HttpServlet {
     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
          out.println("<html>");
          out.println("<head>");
          out.println("<title>Testing custom tags with servlet</title>");
          out.println("</head>");
          out.println("<body bgcolor=pink>");
          out.println("<br><br><br><center>");
          out.println("<form method=post>");
          out.println("<table>");
          out.println("<tr>");
          out.println("<td>Name</td>");
          out.println("<td><input type=text name=userName></td>");
          out.println("</tr>");
          out.println("<tr>");
          out.println("<td>Number</td>");
          out.println("<td><input type=text name=userNo></td>");
          out.println("</tr>");
          out.println("<tr>");
          out.println("<br><br><td><input type=submit value=Submit></td>");
          out.println("<br><br><td><a href=/home/Htmls/test.html>Go to the Shopping Cart</a></td>");
          out.println("</tr>");
          out.println("</table>");
          out.println("</form>");
          out.println("</center>");
          out.println("</body>");
          out.println("</html>");
}Thanks in advance

What is your reason for not wanting test.html in the
web-app directory? Because i want to learn how to forward to a file which is not stored under the web-app directory.
Also, is that href path an
absolute one?I don't know. I have very much confusion over absolute path and relative path. The file is stored under /home/Htmls/test.html. I am using linux OS. And my web-app directory path is /opt/jakarta-tomcat-5.0.25/webapps/Myapp.
Thank you very much for your reply.

Similar Messages

  • Basic FICO doubt regarding posting expenses....

    Hi,
    I am an ABAPer. I have a basic FI doubt. We are using Project system in our company. Now for expenses, the employee enters the data in third party systems. Th third party systems then provide us with the data file which will be posted in SAP.
    The business says that if a given expense by an employee, has Project status released, then the amount for that expense should be posted to cost center otherwise the amount for that expense should be posted to the project(WBS).
    Now what does business people mean by posting expense amount to cost center or posting expense amount to Project (WBS). Where in FI can I see the option of posting amount to cost center versus posting amount to project ? Is there any transaction we can do that ?
    Regards,
    Rajesh.

    when you post to wbs element it is a cost collector which can be settled later, where as cost center is a department. When you have a project, it has on going expenese instead directly posting to a cost center , you are collecting costs in a wbs element and settling it later to cost center. you can post to the wbs element same way as cost center.

  • Nedd to find basic servlet code

    Java novice
    I need basic servlet code that will capture the input of one form field and write it to a flat file on the server. Servlet will be called in html form action. Any good sources to start with? It appears that this is so basic that I've had trouble finding anything out there.
    Thanks

    If what you want is to learn the basic stuff invloved in doing what you want to do.
    Just follow the java servlet tutorial and io tutorial (You can use google to reach those)

  • Basic ABAP doubts

    Hi Experts,
    got some basic doubts..hope ppl can help me tackle them..
    1. y is sapscript client-specific when smartforms are     cross-client ?
    2. why exactly are reference fields required for Currency n Quantity Fields ?
    3. In SE93, while creating a transaction for an executable program, no variant comes in F4 even wen we have created one for the program, n wen we type in the variant, it says the Transaction is inconsistent.. is it because transaction is cross-client whereas variant is not ??
    4. where is DDIC placed?? i mean is it in database or Application server ?
    5. why do we need to have a Value table ?
    Please dont copy & paste from existing sources..it wud be great if u cud explain in ur own wrds...
    all answers wud be appropriately rewarded..
    thanks.
    bikash

    thanks for the reply guys..
    Andreas,it wud ve been better if u explain ur answers.
    pawan.
    1. smartform when activated generates a function module which becomes part of DDIC. so client-independent ... ( arent transparent tables part of DDIC ??? they are client-dependent though )...
    2. bcoz when u say amounts like 1000 rupees, 1000 refers to amount and rupees refers to currency unit.
    thats ok pawan, but how does it matter if it is rupees or USD or EURO..its anyway a field with lets say 13 digits n 2 decimals..n also the field contains only 1000, not the rupees, that part anyway can be got from the currency field.....
    3. did u test in a multiple-client system?? ie, it comes in IDES over here too, i think dats because IDES doesnt have multiple client..
      Also, if it has come in a multiple client system, wat ll happen if u run that transaction in a client in which that variant is not there..it ll throw an error right??
    4. wat my doubt is that anything that is there, also the definitions has to be stored someweher right?? so isnt the database where everything including the dictionary is stored??
    awaiting ur useful responses...
    Message was edited by: Bikash  Agarwal

  • Basic Sensor Doubts

    Hi all,
    I am having some basic doubts regarding the functionality of the sensor.
    case 1
    Assume that sensor is in inline mode.Then
    1) By default "stop" atomic attacks
    2) By default "stop" attacks that span multiple packets
    3) By default block IP address or network addresses without "blocking" being configured?
    In the above case how is "stoping" an attack differnet from blocking it?
    case 2
    Assume that sensor is in promiscous mode
    1) By default "stop" atomic attacks
    2) By default "stop" attacks that span multiple packets
    3) By default block IP address or network addresses without "blocking" being configured
    Also in this case how is "stoping" an attack different from "blocking" an IP or network address?
    Thanks in advance
    MD

    Doesn't blocking actually drop all traffic from that IP for a specified period while dropping or stopping means it drops the packets as they are triggered?

  • Basic Servlet Error...Help Needed Urgently...Losing my patience

    Hi everybody,
    I am very new to servlets and have no idea of JSP. I was reading the book Head First Servlets and JSP and came across a simple servlet in the first chapter...which I am unable to execute for the past 3-4 days after putting more than 5hrs per day..just trying to rectify this issue. My program name is Ch1Servlet.java. My Errors on compiling the code from command prompt is as below.
    I run the following command.
    C:\Sun_Java\Head First Servlet and JSP Examples\Project1\src>javac -classpath C:\Sun_java\Tomcat\Tomcat\lib\servlet-api.jar Ch1Servlet.java
    On execution, the above gives
    Ch1Servlet.java:5: cannot find symbol
    symbol: class HTTPServlet
    public class Ch1Servlet extends HTTPServlet
    ^
    Ch1Servlet.java:7: cannot find symbol
    symbol : class HTTPServletRequest
    location: class Ch1Servlet
    public void doGet(HTTPServletRequest request, HTTPServletResponse response) throws IOException
    ^
    Ch1Servlet.java:7: cannot find symbol
    symbol : class HTTPServletResponse
    location: class Ch1Servlet
    public void doGet(HTTPServletRequest request, HTTPServletResponse response) throws IOException
    ^
    3 errors
    My Program code for Ch1Servlet.java is below:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class Ch1Servlet extends HTTPServlet
         public void doGet(HTTPServletRequest request, HTTPServletResponse response) throws IOException
              PrintWriter out = response.getWriter();
              java.util.Date today = new java.util.Date();
              out.println("<html>"+"<body>"+"<h1 align=center>HF\'s Chapter 1 Servlet</h1>"+"<br>"+"</body>"+"</html>");
    My classpath setting inside User Variables(My Computer Right Clicked and Advanced tab selected. This has Environment variables button...which on clicking gives User variables and System variables window. I created the user variable "CLASSPATH")
    Variable Name: CLASSPATH
    Variable Value: .;C:\Sun_Java\SDK\lib;C:\Sun_Java\SDK\jdk\bin;C:\Sun_Java\Tomcat\Tomcat\lib\servlet-api.jar
    I feel the class path is set correctly....and there are no issues with the code either...It is just that I am unable to import the http package in javax.servlet.http
    My Tomcat version is 6.0
    My J2EE version is Java EE 5 SDK.
    I am not using any editors for the time being. Tomcat server seems to be working perfectly as I could run local host web page which says "Welcome to Tomcat".
    Any help shall be appreciated.
    Thanks,
    Rahul

    You need to pay more attention while reading: it's Http not HTTP, in all places :)
    In almost all Java names ( unfortunately, not all ), you'll find that the name case follows this pattern.

  • Basic Servlet question

    I have a servlet that reads information from a logfile and displays it on the page. The log file is being written as users login and logout to the application. I want the log file to be renamed at midnight exactly to current date. My question is should I have a thread that sleeps till date change and then renames the file and distroy itself. I am new to programming. Would every webuser will be sharing the same thread or every webuser will have a seprate instance of the thread.
    little sample code would be helpfull.
    Thanks in advance!!!

    I would have a thread that sleeps until midnight, then calls a method in your logfile class to have it rename itself and start a new log file. While the renaming occurs, you can synchronize the logging or suspend the logging.

  • Basic JSP doubt

    Hi all,
    I tried developing a simple login application from one of the tutorials available on NET. I have a login.jsp page which takes the Username and password as input and the corresponding form action is done by a login Servlet. But i get the following error
    The requested resource (/onjava/servlet/com.onjava.login) is not available.
    Here is my login.jsp page:
    <html>
    <head>
    <title>OnJava Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#FFFFFF" onLoad="document.loginForm.username.focus()">
    <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td> </td>
    </tr>
    <tr>
    <td>
    <img src="/onjava/images/monitor2.gif"></td>
    </tr>
    <tr>
    <td> </td>
    </tr>
    </table>
    <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <table width="500" border="0" cellspacing="0" cellpadding="0">
    <form name="loginForm" method="post"
    action="servlet/com.onjava.login">
    <tr>
    <td width="401"><div align="right">User Name: </div></td>
    <td width="399"><input type="text" name="username"></td>
    </tr>
    <tr>
    <td width="401"><div align="right">Password: </div></td>
    <td width="399"><input type="password" name="password"></td>
    </tr>
    <tr>
    <td width="401"> </td>
    <td width="399"><br><input type="Submit" name="Submit"></td>
    </tr>
    </form>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>
    Here is my web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
    '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN'
    'http://java.sun.com/j2ee/dtds/web-app_2_3.dtd'>
    <web-app>
    <servlet>
    <servlet-name>login</servlet-name>
    <servlet-class>com.onjava.login</servlet-class>
    </servlet>
    <taglib>
    <taglib-uri>/onjava</taglib-uri>
    <taglib-location>/WEB-INF/lib/taglib.tld</taglib-location>
    </taglib>
    </web-app>
    I have copied the login.class to WEB-INF/classes/com/onjava/ folder. But still i get the same error. Am i doing anything wrong. Please clarify.

    So the tutorial you used is an old one that used the invoker servlet to be able to call un-mapped servlets via /servlet/<class-name>
    This pracice is discouraged now, and most of the time the invoker servlet is turned off.
    Add this to your web.xml after the <servlet> definition:
            <servlet-mapping>
                <servlet-name>login</servlet-name>
                <url>/login</url>
            </servlet-mapping>then change your form tag to have the action="login". This will map the servlet to a url you want to use. You then invoke that url (when the form is submitted) and get the servlet to run.

  • Basic servlet/xml type question

    Hi,
    I have an existing servlet that reads two numbers from a deployment descriptor (web.xml) but i need to modify it so that it displays all the numbers between the two existing numbers in the D. D.
    this is the exisitng servlet:
    response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              // Grab the Parameters from the web.xml file
              String fn = getInitParameter("firstnumber");
         String ln = getInitParameter("lastnumber");
    out.println("<HTML><HEAD><TITLE>ServletContext Init Params</TITLE></HEAD>");
    out.println("<BODY><H1>the numbers are ");
         out.println(fn + " " + ln + "</H1></BODY></HTML>");
    any help would be appreciated.
    Im pretty much a complete novice,
    Regards,
    Stephen.

    A wee bit 'o cross posting here.
    http://forum.java.sun.com/thread.jspa?threadID=713387&messageID=4125474

  • Newbie, basic Servlet logging

    Hello,
    I'm creating a logger in my servlet class:
    private final static Logger logger = Logger.getLogger(MatlabFarm.class.getName());
    Where does the log go by default? I don't see it in my domain/log directory or anywhere in my J2EE installation.
    If I do the following:
    logger.addHandler(new FileHandler(LOGFILE));
    I get the following exception:
    java.security.AccessControlException: access denied (java.util.logging.LoggingPermission control)
    How do I grant J2EE permission to log to this file?

    If you need help for your school, don't come here. I'll assume that this is not for school.
    1:
    // creation of a request dispatcher
    RequestDispatcher rd = request.getRequestDispatcher( "Servlet2" );
    // we can send attributes to the other servlet
    request.setAtribute(  "Attribute1" = "Value1" );
    request.setAtribute(  "Attribute2" = "Value2" );
    // we call the servlet
    rd.forward( request, response);2: as said here: http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/SingleThreadModel.html It ensure that the servlet can only answer to one resquest at a time
    3: Get will appear in url (ex: index.jsp?attribute1=value1) and post won't be visible to the user. When typing a url in your browser and clicking "ok", you're doing a Get request. Post cannot be done without a form with "post " method.
    4. It is in your web.xml config, and it defines whether a servlet is loaded or not on startup. You can give an integer to specify in wich order they're going to be loaded.
    Note that thoses questions were quite easy, and IF you looked for them on google you would have fond them.
    Can you give me Duke stars for the help I provided? THanks :)

  • Basic servlet problem plz help me

    HI all,
    I have installed apache tomcat 5.5 server and set the class path to servlet-api.jar. in environment variable in Edit user variables ----->
    .;C:\Program Files\Java\jdk1.5.0_01\jre\lib\rt.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar
    and i have created a helloworld program :-" FirstSer.java"
    import javax.servlet.;*
    import java.io.*;*
    public class FirstSer extends GenericServlet+
    +*{*+
    *     public void service(ServletRequest req, ServletResponse res) throws ServletException,IOException*
    +*     {*+
    PrintWriter pw=res.getWriter();+
    *      res.setContentType("text/html");*
    *      pw.println("<html><body bgcolor=red>");*
    pw.println("<font size=6 color=white >");+
    *      pw.println("hello good morning");*
    *      pw.println("</font></body></html>");*
    and i've throwed the DOTCLASS in classes folder
    and the WEB.XML in WEB-INF folder
    +<servlet>+
    +*<servlet-name>FirstSer</servlet-name>*+
    +*<servlet-class>FirstSer.class</servlet-class>*+
    +*</servlet>*+
    +*<servlet-mapping>*+
    +*<servlet-name>FirstSer</servlet-name>*+
    +*<url-pattern>bunny/FirstSer</url-pattern>*+
    +*</servlet-mapping>*+
    every thing i have done is that correct .. ?????
    BUT still m unable to deploy the servlet prog . Browser is posting 404 error
    http://localhost:8080/contextroot/FirstSer
    // PLEASE HELP //
    and please explain the procedure and architecture of tomcat context root (its a humble request).
    THANKS IN ADVANCE .

    bunny_aug15 wrote:
    BUT still m unable to deploy the servlet prog . Browser is posting 404 error 404 simply means "Page not found". With other words, the URL used is wrong.
    Let's take a look to your servlet mapping:
    <url-pattern>bunny/FirstSer</url-pattern>So your servlet will only be invoked if your URL matches "bunny/FirstSer".
    Let's take a look how you composed the URL:
    http://localhost:8080/contextroot/FirstSerThat indeed doesn't match. Therefore the 404.
    Solution? Obviously change the url-pattern or invoke it the right way.

  • Basic EJB doubts

    Hi,
    According to the EJB Specification,
    - Entity beans are shared access to the clients. What is it mean?.
    - What is Conversational State in Stateful Session Bean?.
    - Where and when should i use session bean?. Where and when shouldn't i use session bean?.
    - Where and when should i use Entity bean with CMP?.
    - Where and when should i use Entity bean with BMP?.
    Can anyone explain with example?.
    Plz.
    Regards,
    Senthamizh

    Hi,
    It has taken me a year to understand the concept of ejb and still I am not sure whether I should use it or not,In fact I had read the orielly's EJB many times and read the basics again and again then I realized how well it was explained in the Orielly.So if the basics are through the orielly is best for undestanding....
    - Entity beans are shared access to the clients.
    nts. What is it mean?.If you see the forums definition of EJB it says ---->
    The EJB platform handles things like transaction and state management, multithreading, resource pooling, and simple searches while you concentrate on writing business logic..
    The resource pooling explains the shared access point......
    - What is Conversational State in Stateful
    eful Session Bean?.Please refer the Orielly Ejb as it would be very vast to explain.Any way in short the conservational state means the state of the object which is being stored for the particular client...If you still did not understand please get back to me.....
    - Where and when should i use session bean?.
    an?. Where and when shouldn't i use session bean?.
    - Where and when should i use Entity bean with
    with CMP?.
    - Where and when should i use Entity bean with
    with BMP?.Please go through the Orielly and if still you dont get I will try my best to explain......Read the book
    cooly it is easy to understand if you are good at basics....
    regards vickyk

  • Basic bw doubt

    Hi,
    First of all excuse me for asking basic questions.
    assuming i've a ff and i'm trying to load to ods and then onto a cube from the ods. my ff is of this order:
    custid, matid, quantity.
    i;m first loading values like
    cust01 mat01 49
    after loading this i'm loading again with values
    cust01 mat01 83
    how will the records look in ods and in cube
    during reporting how will it look like.
    ~rahul

    Hi,
    as Andrzej already mentioned, your question is a bit unclear but here what I understood.
    You load
    cust01 mat01 49
    and then
    cust01 mat01 83
    to your ods and after that into the cube.
    Now I assume, that custid and matid are the keyfields of your ods and quantity the only data field. If you set the update mode for quantity to overwrite you will see
    cust01 mat01 83
    after both records.
    If you set the update mode to addition you will see
    cust01 mat01 132
    after both records.
    You will see this in your ods as well as in your cube. Basically you might see 49 and 83 if you report also on requestid of your cube. Without requestid it will be just 132.
    Hope this helps!
    regards
    Siggi

  • Basic Java doubt

    Hi,
    I have a small doubt bugging me...
    Can anyone clarify doubt on the exact meaning of Distributed application in java?
    For suppose I have a EJB Application.
    When i can say that my EJB Application is distributed?
    Regards,
    Sivanand

    yawmark wrote:
    gcameo wrote:
    when ur application is devided into components...
    [Ur applications|http://en.wikipedia.org/wiki/Ur] are quite old. Ancient, one might say.
    I think you will find that gcameo it talking about [wild ox|http://en.wikipedia.org/wiki/Ur_(rune)] and components are steaks and oxtail soup.
    Unless you have a very large oven you will need to distribute the load.

  • Basic extraction  doubts sap SAP R/3 to SAP BI

    IN SBIW which radio button i should select if i am extracting the Table in R/3  with 77 fields into sap BI ?
    1) Transaction  or
    2)Master data attributes
    3)texts data
    please tell me ...
    and after that If i want to  use the table for reporting in SAP BI, To which is the best data target to create in SAP BI?
    a)Infocube
    b)DSO
    and please tell me the steps to do in SAP BI system?
    I am asking all these because i am new to sap BI ?
    please do write me...thank you !!!!!!1

    Hi,
    i suppose you need transaction data. We could be sure if you post the table which you want to extract.
    The infoprovider you need is dependent from the data you need for reporting. Pls. search in SDN or in the help.sap.com for modelling help.
    Regards
    Edited by: Zoltan Both on Aug 20, 2008 1:14 PM
    Edited by: Zoltan Both on Aug 20, 2008 1:16 PM

Maybe you are looking for

  • Numbers

    [email protected] Prośba Witam serdecznie! Jesteśmy małą rodzinką,która niedługo się powiększy o jeszcze jednego skarba. Rodzina dla nas jest najważniejsza,dlatego bardzo cenimy sobie czas wspólnie spędzony. Mamy wiele pasji i hobby,które dają nam ra

  • HA SKU configuration - N+1

    Hi all, In my environment i have 3 cisco 5508 controller with release 7.6 . Two controllers are configured as primary and the third controller is configured as a secondary ha-sku, do not have to configure the peer between primary and secondary, but t

  • ITunes and iPad error

    iTunes is stating that it cannot find my iPod when I connect my iPad and am receiving an error message 0xE8000084.  Does anyone know how to fix this issue?

  • Syncing iPad to pc iTunes

    Where is the backup data filed?

  • Airplay audio stopped working

    My roommate has an Apple TV that I used for the first time yesterday. All was well, my mac connected just fine, video and audio. But today when I did exactly what I did yesterday, turned on the apple tv and changed my Macs connection to the Apple TV