Link to servlet

Hi, i have 2 links that load a servlet, i want to difference them in the servlet, i mean i want the servlet know which was the link that called him......i was trying to use the id attribute in the link...but i cant figure out how to use it in the servlet....is there any other way to do it??
<a href="/myservlet" target="marcoder" id="reg">
                Do something
            </a>
<a href="/myservlet" target="marcoder" id="reg">
                Do something
            </a>
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    }

I am sure there must be a way for using the id attribute but I will tell you a better way of doing that
write ur code as following :
Clicked On A
Clicked On B
now in servlet :
String strFlag = request.getParameter("ID");
if(strFlag.equalsIgnoreCase("A"))
//Coming from Link A
else
//Coming from Link B
Hope this helps...
thanks

Similar Messages

  • Differentiating links at servlet

    Hi,
    I'm writing a servlet that could be triggered by links (similar to the page links under google search). I have no idea how the servlet could differentiate between a click on a link to Page 1 or to Page 2. Could anyone help?
    Thanks,
    Sunil.

    In your link, add a parameter ...like:
    link1
    link2
    Then check for it in the servlet, and respond accordingly with:
    String whichPage = request.getParameter("pageProperty");
    if(whichPage != null) {
      if(whichPage.equals("Page1")) {
      else if(whichPage.equals("Page2")) {

  • How to restrice ananymous user access to portal link /irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default?

    Hi experts,
    We had an issue with portal access. I wonder if portal is venerable for security threats?
    Could you please let me how to restrict the unauthorized users (anonymous user) to the portal URL.
    https://HOST:50001//irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default .
    Appreciate your help.
    Regards
    Maruti

    Hi Maruti,
    Hope you are doing good.
    Can't you just amend the portal permissions so that this access is not possible.
    The PCD location should be:
    com.sap.portal.system/security/sap.com/NetWeaver.Portal/no_safety/com.sap.portal.navigation.portallauncher....
    Hope this helps.
    Thank you and have a nice day!
    Kind Regards,
    Hemanth

  • Html link to a servlet

    Hello,
    I am new to Java Servlet programming and I need some help with calling a servlet via a HTML link.
    I have a class which generates a html page:
    package HccMembers;
    public class HccMemberServlet
    public StringBuffer buffer;
    public HccMemberServlet(String sHccId, String sHcId)
    buffer = new StringBuffer(4096);
    this.buffer.append("<HTML>\n ");
    this.buffer.append("<HEAD>\n ");
    this.buffer.append("<TITLE>Members</TITLE>\n");
    this.buffer.append("</HEAD> \n");
    this.buffer.append("<BODY> \n");
    this.buffer.append("<p><ahref='http://localhost:8080/transport/HccMembers/servlet/JCSJobOrderServlet'>New Job Order</a></p>");
    this.buffer.append("</BODY></HTML>");
    Basically, when the user clicks the link a servlet should be invoked. (Below)
    package HccMembers;
    //import java Servlet classes
    import javax.servlet.*;
    import javax.servlet.http.*;
    //import java classes
    import java.io.IOException;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    public class JCSJobOrderServlet extends HttpServlet
    public void init(ServletConfig config) throws ServletException
    System.out.println("hello");
    public void service(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    System.out.println("Hey");           
    The problem is that, when I click the link I get a 404 page not found error. Any ideas?
    I really appreciate any help.

    You need to add couples of lines to the configuration file of your application (web.xml) : first you must say that the class CSJobOrderServlet is a servlet that you want to use, second you must map the servlet to a specific url, then you can use this url whenever you like.
    As an advice, don't use absolute URLs on your application, use only URLs relative to your application root.
    Example for web.xml:
        <servlet>
            <servlet-name> MyFirstServlet</servlet-name>
            <servlet-class>JCSJobOrderServlet</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>MyFirstServlet</servlet-name>
            <url-pattern>/custom_url</url-pattern>
        </servlet-mapping>Now, about the servlet implementation: if you are using System.out.println("Hey") you will see the message on the standard output of the server, and not on the browser as you expected.
    here is a small example:
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response)
          throws IOException, ServletException {
            response.setContentType("text/html");
            PrintWriter writer = response.getWriter();
            writer.println("<html>");
            writer.println("<head><title>Hello response</title></head>");
            writer.println("<body>Hello !</body></html>");
       }For more information see the documentation for servlets and / or a book.
    Iulian

  • Problem with Sessions, Servlets, Netscape and Solaris

    We are experiencing a problem that is confounding and frustrating us (I have
              a felling that it is something exremely minor that we are overlooking).
              Here goes:
              Context:
              The problem only occurs when using a netscape browser against weblogic
              4.51running on our Solaris 7 box (Everything works fine through IE, and
              through both browsers against our development machines which are on NT)
              Problem:
              We have a bunch of JSP pages and servlets that are used togehter throughout
              our site. They both manage session information for the user. What is
              happening is that there is no problem maintaining session information among
              all the JSP pages, but when we hit a servlet that we use to stream graphs
              back to the browser, it gets the session but it has no contents all of a
              sudden. What seems to be even more strange is that the session is not
              tagged as new (by checking isNew()), it is just empty of the contents that
              were placed it by the JSP pages. Again, this is only occurring from
              Netscape browsers against our Solaris server.
              If anyone can provide any help it would be greatly appreciated. I can
              provide more details if need be.
              Jeremy
              

    There is a property in the weblogic.properties file that lets you set
              the cookie name. If this isn't set, the port will be appended as part of
              the name. I've had a similar problem switching between http and https
              and losing sessions.
              Carles
              Jeremy wrote:
              >
              > in the link tothe servlet the URL had a :80 in it. This was because the url
              > was generated by a JSP page so that when it was moved from server to server
              > and port to port the code wouldn't have to be changed. Unfortuneately,
              > Netscape sucks and takes this to mean that x.x.x.x and x.x.x.x:80 are
              > different and won't acknowledge the cookie from the JSP pages (x.x.x.x) to
              > the servlet (x.x.x.x:80). Thanks fpr your help.
              >
              > Jeremy <[email protected]> wrote in message
              > news:[email protected]...
              > > my mistake, it appears to always happen on port 80 regardless of the
              > server
              > > it is on.
              > >
              > > Jeff Martin <[email protected]> wrote in message
              > > news:[email protected]...
              > > > It really sounds like your servlet is making a new session, even though
              > > > isNew() doesn't say so. What you might try to do is use session.getId()
              > > > to print out the session ID from your jsp pages as well as your servlets
              > > > to determine if it really is a new session.
              > > >
              > > > Do your servlets and JSPs both use the same scheme (http or https) or
              > > > cookie.setSecure()? Do your cookies use domains or paths in either
              > > > servlets or jsps (cookies can be restricted to certain subdirectories
              > > > which might be different between jsps and servlets)? Are you testing
              > > > through a proxy or firewall, or does either browser have different proxy
              > > > settings than the others?
              > > >
              > > > Jeff
              > > >
              > > > Jeremy wrote:
              > > > >
              > > > > We are experiencing a problem that is confounding and frustrating us
              > (I
              > > have
              > > > > a felling that it is something exremely minor that we are
              > overlooking).
              > > > > Here goes:
              > > > >
              > > > > Context:
              > > > > The problem only occurs when using a netscape browser against weblogic
              > > > > 4.51running on our Solaris 7 box (Everything works fine through IE,
              > and
              > > > > through both browsers against our development machines which are on
              > NT)
              > > > >
              > > > > Problem:
              > > > > We have a bunch of JSP pages and servlets that are used togehter
              > > throughout
              > > > > our site. They both manage session information for the user. What is
              > > > > happening is that there is no problem maintaining session information
              > > among
              > > > > all the JSP pages, but when we hit a servlet that we use to stream
              > > graphs
              > > > > back to the browser, it gets the session but it has no contents all of
              > a
              > > > > sudden. What seems to be even more strange is that the session is not
              > > > > tagged as new (by checking isNew()), it is just empty of the contents
              > > that
              > > > > were placed it by the JSP pages. Again, this is only occurring from
              > > > > Netscape browsers against our Solaris server.
              > > > >
              > > > > If anyone can provide any help it would be greatly appreciated. I can
              > > > > provide more details if need be.
              > > > >
              > > > > Jeremy
              > >
              > >
              

  • How to create a link

    i have to create a link in servlets ,this link should pop up a file where in client can modify this file & should be able to save it , i should also be able to receive this modified file.
    I have absolutely no idea of how to start can anyone on the line help me plzzzzzzzz
    cheers,
    vishal j

    html, has a file input tag
    <input type="file" name="orig_name" accept="text/html"/>
    as an example
    A form that includes a file INPUT must specify METHOD=post and ENCTYPE="multipart/form-data" in the <FORM> tag.

  • How to set Bind variable on the action of command link

    I have two tables. One is the list of processes and other one is the details of processes with process name as primary key.
    I want to first display the first table which has the list of processes on one page. When I click on perticular process name this process will pass to the bind variable of another table and corresponding details will be shown on other page. can anyone help how I can do this. My code is as follows:
    package model;
    import model.common.BpelDetailsView;
    import oracle.jbo.server.ViewObjectImpl;
    public class BpelDetailsViewImpl extends ViewObjectImpl implements BpelDetailsView {
    * This is the default constructor (do not remove).
    public BpelDetailsViewImpl() {
    * Returns the variable value for bpelnameVar.
    * @return variable value for bpelnameVar
    public String getbpelnameVar() {
    return (String)ensureVariableManager().getVariableValue("bpelnameVar");
    * Sets <code>value</code> for variable bpelnameVar.
    * @param value value to bind as bpelnameVar
    public void setbpelnameVar(String value) {
    ensureVariableManager().setVariableValue("bpelnameVar", value);
    this.executeQuery();
    <af:commandLink id="ot3" text="#{row.BpelName}"
    action="#{DasboardBean.ot3_action}"/>
    public String ot3_action() {
    BpelDetailsViewImpl bdv=new BpelDetailsViewImpl();
    bdv.setbpelnameVar("#{row.BpelName}");
    return "success";
    but its not working at all.
    Its displaying the errors on click of command link.
    javax.servlet.ServletException: java.lang.NullPointerException
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:54)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:147)
         at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:271)
         at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:140)
         at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:364)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:87)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:298)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:91)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:87)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:87)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:298)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:91)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:81)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:673)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:273)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:165)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         ... 34 more
    Caused by: java.lang.NullPointerException
         at oracle.jbo.server.ComponentObjectImpl.ensureVariableManager(ComponentObjectImpl.java:472)
         at model.BpelDetailsViewImpl.setbpelnameVar(BpelDetailsViewImpl.java:32)
         at portal.view.bean.DasboardBean.ot3_action(DasboardBean.java:24)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
         ... 54 more

    Hi Shay..
    Thanx for your help...
    I stuck in one more problem. When I run directly the first list page it works fine. I craeted one more page home.jspx where I added a golink with <af:golink id="gl1" text ="List" destination="list.jspx". When I click on link it opens the list page. Now when I clicking on first column its redirecting to list.jspx not to details.jspx.
    What can be the solution for this.

  • Open excel sheets in separate windows by clicking link.

    Hi,
    I have a web page which has a link. When user clicks on the link, a servlet is invoked that creates an excel sheet and opens it in MS-Excel. I used "res.setContentType("application/vnd.ms-excel");" to achieve this.
    But every time I click the link it opens up the sheet on the same MS-Excel window. It doesn't open up the excel sheet in new other window.
    Now here is my requirement: Whenever user clicks on the link, a new MS-Excel window should open up containing the excel sheet. So if user clicks the link 3 times, then 3 separate window should open up each containing its own excel sheet.
    Can anyone help me out in achieving this?
    Thanks in advance...

    Hi, try this
    In JSP/HTML
    Export To Excel
    In Servlet
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-disposition","attachment; filename=MyProjectExport.xls" );
    In web.xml
      <servlet>
        <servlet-name>excelservlet</servlet-name>
        <servlet-class>myPackage.ExcelServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>excelservlet</servlet-name>
        <url-pattern>/MyProjectExport.xls</url-pattern>
      </servlet-mapping>Assuming I haven't made any typos obfuscating the real packages, it
    should work. I think the step you are missing is to add the servlet
    mapping so that the servlet name is MyProjectExport.xls
    In the example above, I've made my servlet name match the filename in
    the Content-disposition, though in my real application it deosn't seem to
    matter that they don't match. In the html, you link to the name of the
    servlet, rather than the filename, but if you name them the same, I
    guess it won't matter.
    Arth

  • Capture Unix Terminal TTY from Servlet or JSP

    I have a WEB Application (Servlets/JSP), that run in Tomcat. This aplication serve pages to IE and Links (Text Browser). I need that browser send a tty name, in case to use unix sco links, to servlet. How to do this? Help me please!!!!!

    From your servlet, you can try this...
    String browserType = request.getHeader("User-Agent")
    ...and see if this tells you whether or not you're using Lynx

  • Calling servlet from hyperlink

    Hi all,
    how can I call a servlet from an html hyperlink, I tried this code but it says the resource is not available

    It seems you placed html in another folder and called the servlet with it's relative name
    for eg :
    your html is in folder webapps\myapp\servlet\html
    and your servlets servlet-mapping may be myapp/servlet/servlet1
    In that case if you used the link as "/servlet/servlet1" in your html the tomcat will parse it as myapp /servlet/html/servlet/servlet1
    For this use the complete path "http://*.*.*/myapp/servlet/servlet1"
    or use "../servlet1"

  • Transfering data between servlets

    hi
    how would i transfer data between servlets - Im creating a form (form1) which asks the user to enter information - the user then submits, and this takes them to the next form (form2) - i need to transfer the data from form1 to form2 (ie. name, lastname). code follows
              // set content type
              response.setContentType("text/html");
              // then write the data of the response
              out = response.getWriter();
              out.println("<HTML><HEAD><TITLE>" + Title + "</TITLE></HEAD><BODY BGCOLOR=white>");
              out.println("<H2>Customer Registration Form</H2>");
              //create link to servlet action = pathOfServlet?
              out.println("<FORM action = \"ServletExample1\">");
              out.println("First name: <input type=text name=\"name\" value=\"" + name + "\">");
              out.println("Last Name: <input type=text name=\"lastName\" value=\"" + lastName + "\"><P>");
              //value=\"female\" -- forward slash enters html/java and ends java
              out.println("Male<input type=radio name=\"gender\" value=\"male\"> ");
              out.println("Female<input type=radio name=\"gender\" value=\"female\"><P>");
              out.println("Telephone: <input type=text name=\"phone\" value=\"" + phone + "\">");
              out.println("Email: <input type=text name=\"email\" value=\"" + email + "\"><P>");
              out.println("<INPUT TYPE=SUBMIT><P>");
              out.println("</FORM>");
              // then write the data of the response
              out = response.getWriter();
              out.println("<HTML><HEAD><TITLE>" + Title + "</TITLE></HEAD>\n");
              out.println("<BODY BGCOLOR=white>");
              out.println("<H3>Credit Card Information</H3>");
              out.println("<FORM>");
              out.println("First name: <input type=text name=\"name\" value=\"" +should i link here+ "\">");
              out.println("</BODY></HTML>");

    Have you tryed using the request parameter? It should contain what you seek, I think.
    Here for example;
    String firstName = request.getParameter("name");
    String lastName = request.getParameter("lastname");Use that in the second form, which should get its parameters from form1.

  • Display a cruve and a table in the same servlet

    Hi,
    I want to display a curve in a servlet, I can do it, but I can't display the table which is after the curve, the code is the following :
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
           XYDataset dataset = createDataset(pathFile, pathFileTimer);
          JFreeChart chart = createChart(dataset);
          resp.setContentType("image/png");
          OutputStream out1 = resp.getOutputStream();
          ChartUtilities.writeChartAsPNG(out1, chart, 800, 600);
          out1.close();
          PrintWriter out = resp.getWriter();
          out.println("<html>");
          out.println("<body>");
          out.println("<head>");
          out.println("<title>Informations batterie</title>");
          out.println("</head>");
          out.println("<body bgcolor=\"white\">");
          out.println("<TABLE id=\"Table1\" style=\"WIDTH: 864px; HEIGHT: 75px\" cellSpacing=\"1\" cellPadding=\"1\" width=\"864\" border=\"1\">");
    ...So how can I display the table in the same servlet ? Or perhaps can I display the curve in an another servlet, but it would be better to call this servlet automatically and not manually with a post method.
    Thanks for any help.

    So how can I display the table in the same servlet ?You can't. You either send HTML or you send PNG. You can't combine the two in the same request.
    Or perhaps can I display the curve in an another
    servlet, but it would be better to call this servlet
    automatically and not manually with a post method.Yes, you would use another servlet to display the curve. Servlet A would generate the HTML, including a link to Servlet B. I don't know what you think the difference between calling a servlet automatically and manually is, but if you use this two-step process:
    1. Decide what HTML you want the browser to see.
    2. Write code to produce that HTML.
    you will find things a lot less confusing.

  • Servlet Context in a Nutshell??????

    I am a newcomer to Servlets and relatively new to Java. I have not found a very clear explanation of what a servlet "Context" is and can therefore only assume that its so simple as to not need further explanation.
    Here goes;
    1. You write your Servlet code, compile it.
    2. If you add this Servlet to the classes directory of a web-app called "MyWebApp" then the context for that particular servlet is "/MyWebApp"
    3. Adding it to the classes directory of other web apps gives a different "context" for each one.
    4. You can add a servlet to a web-app ("context") by adding the servlet URI to the deployment descriptor of the web-app????????(THis one I am really not sure of)
    Summary: The context of a particular servlet is the name of the particular web-app within which it resides or is referred to
    Maybe some of you experts out there could shed some light on this and I could create a document explaing context a post it on the web sowmwhere for other poor beginners like myself.
    Thanks in advance.

    Well, some experts will wanna kill me for told that, but, lets go....
    Comparing with the JVM, a context is like a class path (of course they have many differences). In other worlds the context is a directory (or war file) where the web server (for example TOMCAT) wiil search your .class files (or.war, .jar, etc...)
    All context are "pointed" to a dir, for example you can point the context /myapps to a dir of your OS (for example /home/your_username or in a windows system - C:\Program Files.
    Then when you acces this context at the browser, the browser will show this directory hierarchy. For you execute your servlet you need to create a WSDL (the descritor file). This file is nothing more than a XML document (that had rules) and link a servlet at a context, (for example the servlet Hello can pointed to the path /hello, and then, this servlet is "install" at the context /myapps). After this, you can access your servlet at the path http://computer_address/myapps/hello.
    Note: Step by step, you need:
    1) create the web application strucuture directory (the WEB-INF, classes, etc...)
    2) write the servlet
    3) write the web.xml
    4) compile the servlet
    5) create a context - point the context to the web app structure "father"
    6) install this servlet at the context
    7) access the servlet
    I hope this help you to understand some things, but for learning I recomended the Tomcat manual!!!! Good Luck.
    Giscard

  • Getting servlet context in a web service

    Hi,
    I have a problem but have no solution to it and am not sure of the approach.
    I am creating a web service. Some parameters will be passed to this web service. I need to capture these parameters and put it in a hash table so that it is available to another applicatins servlet context i.e.
    there will be two calls .
    first the web service is invoked and the parameter is stored in the hash table of the applications servlet context.
    Next when the application is invoked it shud refer to the hash table and get the data in the hash table that was stored by the web service and process it.
    How can this be achieved?

    Well, some experts will wanna kill me for told that, but, lets go....
    Comparing with the JVM, a context is like a class path (of course they have many differences). In other worlds the context is a directory (or war file) where the web server (for example TOMCAT) wiil search your .class files (or.war, .jar, etc...)
    All context are "pointed" to a dir, for example you can point the context /myapps to a dir of your OS (for example /home/your_username or in a windows system - C:\Program Files.
    Then when you acces this context at the browser, the browser will show this directory hierarchy. For you execute your servlet you need to create a WSDL (the descritor file). This file is nothing more than a XML document (that had rules) and link a servlet at a context, (for example the servlet Hello can pointed to the path /hello, and then, this servlet is "install" at the context /myapps). After this, you can access your servlet at the path http://computer_address/myapps/hello.
    Note: Step by step, you need:
    1) create the web application strucuture directory (the WEB-INF, classes, etc...)
    2) write the servlet
    3) write the web.xml
    4) compile the servlet
    5) create a context - point the context to the web app structure "father"
    6) install this servlet at the context
    7) access the servlet
    I hope this help you to understand some things, but for learning I recomended the Tomcat manual!!!! Good Luck.
    Giscard

  • How do i track clicks with jsp/servlets?

    I would like to know how to imitate the click of link in JSP or serlvet, in order to track clicks.
    I have pages with links containing tel protocol URIs like this:
    Click here to listen!
    I want to replace the above with something like this:
    Click here to listen!
    And have call_tracking.jsp do its tracking stuff and then spawn a phone call, just like the first example does. I do not want to bother the user with another page, hence the need to accomplish the click action programmatically. I presume this feat is achievable via Response header magic, I just don't know the right incantation ;-)
    Thanks

    You should create a servlet to track the links, let´s say LinkTracker. Here I have an example for you. Each link calls a servlet and pass the url as a parameter.
    <html>
      <head>
        <title>Some Links Tracked by the LinkTracker Servlet</title>
      </head>
      <body>
      Some good links for you. Each link is directed
      through the LinkTracker Servlet. Click on a few and visit
      the <a href="LinkTracker">LinkTracker Servlet</a>.
      <ul>
        <li><a href="LinkTracker?link=http://www.google.com">
          Google Site</a></li>
        <li><a href="LinkTracker?link=http://www.yahoo.com">
          Yahoo site</a></li>
        <li><a href="LinkTracker?link=http://java.sun.com">
          Sun Microsystems</a></li>
      </ul>
      </body>
    </html>And here the code to LinkTracker servlet
    public class LinkTracker extends HttpServlet {
      static private Hashtable links = new Hashtable();
      String tstamp;
      public LinkTracker() {
        tstamp = new Date().toString();
      public void doGet(HttpServletRequest request,
                        HttpServletResponse response)
        throws IOException, ServletException {
        String link = request.getParameter("link");
        if (link != null && !link.equals("")) {
          synchronized (links){
            Integer count = (Integer) links.get(link);
            if (count == null) {
              links.put(link, new Integer(1));
            else {
              links.put(link, new Integer(1+count.intValue()));
          //here the servlet redirect the client to the link he clicked
          response.sendRedirect(link);
        else {
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
          request.getSession();
          out.println("<html>");
          out.println("<head>");
          out.println("<title>Links Tracker Servlet</title>");
          out.println("</head>");
          out.println("<body>");
          out.println("<p>Links Tracked Since");
          out.println(tstamp+":</p>");
          if (links.size() != 0) {
            Enumeration enum = links.keys();
            while (enum.hasMoreElements()) {
              String key = (String)enum.nextElement();
              int count = ((Integer)links.get(key)).intValue();
              out.println(key+" : "+count+" visits<br>");
          else {
            out.println("No links have been tracked!<br>");
          out.println("</body>");
          out.println("</html>");
      public void doPost(HttpServletRequest request,
                        HttpServletResponse response)
        throws IOException, ServletException {
        doGet(request, response);
    }

Maybe you are looking for

  • Error in the report for costumers in Crystal

    In the Crystal Sales Report whenever a user tries to display the results from all the customers when entering the values in order to display a report for a particular customer, the scroll only shows customers starting from letters A to M instead of s

  • Cannot print to Canon MF8380Cdw

    I've been trying for a couple of weeks to get my Canon MF8380Cdw to print from my workhorse MacBook Pro running Lion. I've installed the latest version of the driver, repaired permissions, uninstalled/reinstallled, etc. but I can't ever seem to get "

  • How can I get rid of this ridiculous Inbox Page !!!! ????

    Instead of the firefox page opening up on bootup , a page called "inbox" opens up. This is most unsatisfactory for me and I cannot remove it as a default page . It seems to be a Creature of firefox ?? If so I'm moving to Google Chrome or similar. Tha

  • I need to be able to talk to a real person at apple, not a service tech.

    I have taken my 8 year old mac book pro to apple and also to an independent apple authorized repair business. The screen will not work. Apple told me that they could not fix it even though I was sure it was the same problem my son's mac book pro had,

  • Output to line printer (132 x 66)

    I need to print statement to a Line Printer (such as Epson LQ-1600K) on preprinted form. Should I use character mode? I've tried to setup a character mode report as described in Daily BI Views (except output chr(14) to printer) The layout of printout