This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to set conf file file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to set conf file file" Watch "How to set conf file file" New topic
Author

How to set conf file file

maha devan
Ranch Hand

Joined: Mar 16, 2004
Posts: 50
Hi members I am Beginner in servlets

Actually I have written a small servlet. Compiled it and placed it inside the WEB-INF/classes folder.
I have also written the mapping in xml as follows
<servlet>
<servlet-name>
servletToJsp
</servlet-name>
<servlet-class>
ServletSample
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
servletToJsp
</servlet-name>
<url-pattern>
/servletToJsp
</url-pattern>
</servlet-mapping>

How to open it on Browser .At present I tried something like this
http://localhost:8080/sampleworks/ServletToJsp and got error
How could i do it..I am using Tomcat.

Anybody pls
Maha
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Use following URL

http://localhost:8080/ServletToJsp
maha devan
Ranch Hand

Joined: Mar 16, 2004
Posts: 50
Hi Ali

I tried that URL I am getting error Like this

type Status report

message /ServletToJsp

description The requested resource (/ServletToJsp) is not available.

U see I even restarted Tomcat. As somebody told it will take effect only after restarting.

Maha
maha devan
Ranch Hand

Joined: Mar 16, 2004
Posts: 50
For more clarity
I am having a main folder samplworks inside webapps.
sampleworks/WEB-INF/classes/ServletSample.class
sampleworks/WEB-INF/web.xml

Thanks
maha
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Sorry i have written the capital "S". Use http://localhost:8080/servletToJsp
It should work.
maha devan
Ranch Hand

Joined: Mar 16, 2004
Posts: 50
I had tried the URL http://localhost:8080/servletToJsp
Same error is coming
But if I try
http://localhost:8080/sampleworks/servletToJsp
I am getting the error as follows

root cause

java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class ServletSample with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)

Thanks
Maha
maha devan
Ranch Hand

Joined: Mar 16, 2004
Posts: 50
I am pasting my code over here

import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
class ServletSample extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
{
response.setContentType("Text/html");
try
{
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<B> Hi ");
out.println("</html>");
out.println("</body>");
}
catch(IOException e)
{}
}
}

Thanks Maha
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
In deployment descriptor you have used

<servlet-class>
ServletSample
</servlet-class>



Use full name of the class with package name. Like


Here instead of package_name write the package in which you have made the ServletSample Servlet.
May be this will work.
maha devan
Ranch Hand

Joined: Mar 16, 2004
Posts: 50
Hi Ali Thanks for that Now the servlet it tryig to open

But I get an Error like this

root cause
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class ServletSample with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
at java.lang.Class.newInstance0(Class.java:302)

Whats this error About.
I think I have posted my code also pls look over

Thanks
Maha
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Make your servlet class as public.
maha devan
Ranch Hand

Joined: Mar 16, 2004
Posts: 50
Thanks Ali
At last it worked
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set conf file file
 
Similar Threads
Problem with URL-PATTERN tag
Need configuration
invoking servlets differently
http status 404 The requested resource is not available.
How to debug a servlet