0

Hi all,

I need to hide or change my jsp URL. i tried with following code with xml but still its not working.Any pls help me for this..

<servlet>
   <servlet-name>User</servlet-name>
    <jsp-file>User.jsp</jsp-file>
 </servlet>
   <servlet-mapping>
    <servlet-name>User</servlet-name>
    <url-pattern>/UserPage</url-pattern>
  </servlet-mapping>

Edited by anand01: n/a

3
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by anand01
-1

I dnt know how to hid url in jsp..but you can change the url in hear....
you dont need to use actual path in hear...you can change it your own,,,

0

thanks Sadun89,
Ya I used different name only but its not working .Its shows server error

0

@Sadun89 forum rules require you use proper English. Either start typing properly or find some to teach you

@anand01 you can find working example of mapping in this post

0

thanks peter_budo,

1) Ya am studying from your MVC post only. I know to how use servlet mapping code for servlets but i need to do that for jsp pages i tried with above code but its not working.

2) the next thing i need to ask with u is I don't know how to read param value from multiple servlet. i,e I need to access db from LoginServlet and UserServlet how can I read driver,dburl,dbusername values which already in xml file.I can achieve this in single servlet dont know for multiple servlet pls guide me

Thanks in advance

0

1) Similar principle as used on servlets can be used on pages (sorry can't help more as I'm going away till Tuesday, but if you search for JSP URL mapping you should find something useful)

2) Same way as you get connection for your login page through data manager do it any other servlet where you need to communicate with database (one of the reason why it was put in separate class to avoid duplication of whole DB connect and close in every servlet that may have need for connectivity)

Edited by peter_budo: n/a

0

Thanks a lot peter_budo,

xml code for LoginServlet

<servlet>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>LoginServlet</servlet-class>
    <init-param>
      <param-name>jdbcDriver</param-name>
      <param-value>com.mysql.jdbc.Driver</param-value>
    </init-param>
    <init-param>
      <param-name>dbURL</param-name>
      <param-value>jdbc:mysql://localhost:3306/invoice</param-value>
    </init-param>
    <init-param>
      <param-name>dbUserName</param-name>
      <param-value>root</param-value>
    </init-param>
</servlet>

Should I write xml code for UserServlet like this

<servlet>
    <servlet-name>UserServlet</servlet-name>
    <servlet-class>UserServlett</servlet-class>
    <init-param>
      <param-name>jdbcDriver</param-name>
      <param-value>com.mysql.jdbc.Driver</param-value>
    </init-param>
    <init-param>
      <param-name>dbURL</param-name>
      <param-value>jdbc:mysql://localhost:3306/invoice</param-value>
    </init-param>
    <init-param>
      <param-name>dbUserName</param-name>
      <param-value>root</param-value>
    </init-param>
</servlet>

Edited by anand01: n/a

0
<servlet>
   <servlet-name> MyName </servlet-name>
   <servlet-class> myPackage.MyServlet </servlet-class>
</servlet>

<servlet-mapping>
   <servlet-name> MyName </servlet-name>
   <url-pattern>/AnyNamme </url-pattern>
</servlet-mapping>

This is the way to change URl servlets....

First we should identify where the place that servlet-class located
than give some name to it...It not want to be your servlet name...

after you put the name above you mention,within "Servlet-name" tags in "Servlet mapping"
than give any name to servlet that what u want to show in your browser..
note Don't forget start name with "/"

after that you can try using your new servlet name

I think its work...if not let see...:)

Edited by peter_budo: Keep It Clear - Do use code tags when posting any code

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.