Erick Martin

Greenhorn
+ Follow
since May 17, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Erick Martin

The deployment descriptor has the required mapping for the servlet. As you can see the FileNotFoundException is being caught within the servlet.
When the mappings r not ok, you get a different kind of error, like "resource not available" or something like that.
Any other ideas anyone? Thanks,
[ June 07, 2002: Message edited by: Erick Martin ]
21 years ago
Hi everybody, the following class <URLMappingsXmlDAO> it is supposed to print out all the elements of <whatever.xml> file for testing purposes. It is invoked from a servlet <MyServlet>
<MyServlet> is sitting @ WEB-INF/classes/com/mydomain/controller/
<URLMappingsXmlDAO> @ WEB-INF/classes/com/mydomain/controller/web/
<whatever.xml> @ WEB-INF/
I keep getting a FileNotFoundException, for some reason it cannot find the xml file.
Any suggestions? Thanks in advance,

package com.mydomain.controller.web;
import java.io.FileReader;
import java.io.IOException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
import org.apache.xerces.parsers.SAXParser;
public class URLMappingsXmlDAO extends DefaultHandler
{

public static void loadDocument(String location) throws SAXException, IOException {
XMLReader xr = new org.apache.xerces.parsers.SAXParser();
URLMappingsXmlDAO handler = new URLMappingsXmlDAO();
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
FileReader r = new FileReader(location);
xr.parse(new InputSource(r));
}

}
This is the calling servlet:
package com.mydomain.controller;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.NamingException;
import javax.naming.InitialContext;
import com.mydomain.controller.web.URLMappingsXmlDAO;
public class MyServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
try {
URLMappingsXmlDAO.loadDocument("/WEB-INF/whatever.xml");
}
catch (org.xml.sax.SAXException ex) {
System.err.println("SAX Driver: " + ex);
}
catch (IOException ex) {
System.err.println("File: " + ex);
}
}
}
21 years ago
Hi everybody, the following class <URLMappingsXmlDAO> it is supposed to print out all the elements of <whatever.xml> file for testing purposes. It is invoked from a servlet <MyServlet>
<MyServlet> is sitting @ WEB-INF/classes/com/mydomain/controller/
<URLMappingsXmlDAO> @ WEB-INF/classes/com/mydomain/controller/web/
<whatever.xml> @ WEB-INF/
I keep getting a FileNotFoundException, for some reason it cannot find the xml file.
Any suggestions? Thanks in advance,

package com.mydomain.controller.web;
import java.io.FileReader;
import java.io.IOException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
import org.apache.xerces.parsers.SAXParser;
public class URLMappingsXmlDAO extends DefaultHandler
{

public static void loadDocument(String location) throws SAXException, IOException {
XMLReader xr = new org.apache.xerces.parsers.SAXParser();
URLMappingsXmlDAO handler = new URLMappingsXmlDAO();
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
FileReader r = new FileReader(location);
xr.parse(new InputSource(r));
}

}
This is the calling servlet:
package com.mydomain.controller;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.NamingException;
import javax.naming.InitialContext;
import com.mydomain.controller.web.URLMappingsXmlDAO;
public class MyServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
try {
URLMappingsXmlDAO.loadDocument("/WEB-INF/whatever.xml");
}
catch (org.xml.sax.SAXException ex) {
System.err.println("SAX Driver: " + ex);
}
catch (IOException ex) {
System.err.println("File: " + ex);
}
}
}
[ May 31, 2002: Message edited by: Erick Martinez ]
Hi Erick, try just placing your InsertTag into
WEB-INF/classes/com/mydomain/view/template/tags
it should work then.
21 years ago
JSP
Hi there, this topic is not new but so far I don't seem to get it working.
This is my .tld file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>templateTLD</short-name>
<uri>/tlds</uri>
<display-name>templateTLD</display-name>
<description>Template Tags</description>
<tag>
<name>insert</name>
<tagclass>com.mydomain.view.template.tags.InsertTag</tagclass>
<body-content>JSP</body-content>
<small-icon></small-icon>
<large-icon></large-icon>
<description>An insertion tag</description>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>String</type>
</attribute>
<attribute>
<name>template</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>String</type>
</attribute>
</tag>
</taglib>
AND here is JSP where I'm using this library
<%@ taglib uri="/templateTLD" prefix="template" %>
<template:insert template="/templates/sidedTemplate.jsp">

</template:insert>
There is an entry into web.xml reading :
<taglib>
<taglib-uri>/templateTLD</taglib-uri>
<taglib-location>/WEB-INF/tlds/barSidedTemplate.tld</taglib-location>
</taglib>
When invoking the JSP file, I get the following error:
Unable to load class com.mydomain.view.template.tags.InsertTag
barSidedTemplate.tld is sitting @ WEB-INF/tlds
InsertTag is under WEB-INF/classes/com/mydomain/servlets/view/template/tags
This is the package name: package com.mydomain.view.template.tags;
I am using JRun.
Any suggestions? Thanks in advance.
[ May 30, 2002: Message edited by: Erick Martinez ]
21 years ago
JSP
Hi Dave, thanks for both your suggestion and advice. I got it working right. By the way, for anyone else reading this posting here it is how the solution should look like:
<A HREF="<%= response.encodeURL("yourPage.jsp") %>">Linked Text </A>
I also had to add the encodeURL to the ACTION tag in the form calling my servlet:
<FORM ENCTYPE="multipart/form-data" NAME="FormName" METHOD="POST" ACTION="<%= response.encodeURL("yourServlet") %>">
21 years ago
Hi everybody. I am developing a web application following the MVC pattern. I have the feeling my so called �session problem� is quite trivial, but this is the price one has to pay when moving from the back-end scene to the jsp-servlet world. This is the scenario:
View:
There are a few pages having static content. For these pages the structure is as follow:
pageName.jsp � contains custom tags template
pageName.html � the actual content of the page
To increase performance, I use direct html links to access these pages, skipping over the main controller. So far, so good.
Controller:
MainServlet is the main controller. At this point it only does simple redirecting, you can take a peek at code below:
----------------------------
public class MainServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
doProcess(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
doProcess(request, response);
}
private void doProcess(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String nextScreen = null;
HttpSession session = request.getSession(true);
session.setAttribute("whateverAttribute", "attributeValue");
nextScreen = request.getParameter("currentScreen");
if (nextScreen == "x") {
gotoPage("/page1.jsp", request, response);
} else if (nextScreen == "admin") {
gotoPage("/page2.jsp", request, response);
} else {
gotoPage("/default.jsp", request, response);
}
}
private void gotoPage(String address, HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(response.encodeURL(address));
dispatcher.forward(request, response);
}
}
------------------------
The problem:
I need to keep the session information generated in MainServlet (whateverAttribute=attributeValue) available to all my static jsp pages and eventually to other servlets, but every time I go to a new page I get a different session ID.
There are some conditional pieces of content to be embedded into the custom tags template, depending on session info.
Can anybody bring some enlightment to this troubled collegue? Thanks in advance,
[ May 17, 2002: Message edited by: sillyAgent ]
21 years ago
JSP
Hi everybody. I am developing a web application following the MVC pattern. I have the feeling my so called �session problem� is quite trivial, but this is the price one has to pay when moving from the back-end scene to the jsp-servlet world. This is the scenario:
View:
There are a few pages having static content. For these pages the structure is as follow:
pageName.jsp � contains custom tags template
pageName.html � the actual content of the page
To increase performance, I use direct html links to access these pages, skipping over the main controller. So far, so good.
Controller:
MainServlet is the main controller. At this point it only does simple redirecting, you can take a peek at code below:
----------------------------
public class MainServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
doProcess(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
doProcess(request, response);
}

private void doProcess(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String nextScreen = null;

HttpSession session = request.getSession(true);
session.setAttribute("whateverAttribute", "attributeValue");

nextScreen = request.getParameter("currentScreen");
if (nextScreen == "x") {
gotoPage("/page1.jsp", request, response);
} else if (nextScreen == "admin") {
gotoPage("/page2.jsp", request, response);
} else {
gotoPage("/default.jsp", request, response);
}
}

private void gotoPage(String address, HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(response.encodeURL(address));
dispatcher.forward(request, response);
}
}
------------------------
The problem:
I need to keep the session information generated in MainServlet (whateverAttribute=attributeValue) available to all my static jsp pages and eventually to other servlets, but every time I go to a new page I get a different session ID.
There are some conditional pieces of content to be embedded into the custom tags template, depending on session info.
Can anybody bring some enlightment to this troubled collegue? Thanks in advance,
[ May 17, 2002: Message edited by: Erick Martinez ]
21 years ago