need a solution, plz...

Hi, guys, i would like to ask you,

It抯 difficult to explain but say i have jsp page:

from_db.jsp

<.code>

<a href=from_db.jsp?parent_name=?PARENT_NAME+?gt; NAME </a>

Path: <a href=from_db.jsp?parent_name=?PARENT_NAME_1+?gt;NAME_1</a> / <a href=from_db.jsp?parent_name=?PARENT_NAME_2+?gt;NAME_2</a> ...

</.code>

Every time i click on NAME (witch is every time different) i need to built a path, whitch is collected from different PARENT_NAMES on the same from_db.jsp. i hope you understood.

Any suggestions? Thanks in advanced.

[620 byte] By [newj87a] at [2007-11-27 4:05:11]
# 1

I assume that PARENT_NAME is a String variable in your JSP scriptlet page.

If you would like to place the value of PARENT_NAME rather than just, +PARENT_NAME+ then you need to change your code like this.

<a href=from_db.jsp?parent_name=?lt;%= PARENT_NAME %>?gt; NAME </a>

maple_shafta at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 2
> i hope you understood.No.> Any suggestions?- Try again.- Use the forum's code tags
quittea at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 3

thanks for replay maple_shaft yes yes you are right PARENT_NAME is a String:

Hi, guys, i would like to ask you,

It抯 difficult to explain but say i have jsp page:

from_db.jsp

<.code>

<a href=from_db.jsp?parent_name=<%PARENT_NAME%> NAME </a>

Path: <a href=from_db.jsp?parent_name=<%PARENT_NAME_1%>NAME_1</a> / <a href=from_db.jsp?parent_name<%=PARENT_NAME_2%>NAME_2</a> ...

</.code>

Every time i click on NAME (witch is every time different) i need to built a path, whitch is collected from different PARENT_NAMES on the same from_db.jsp. i hope you understood.

Any suggestions? Thanks in advanced.

newj87a at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 4
Looks like a job for an array and a loop. What exactly is your question?
quittea at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 5

Should i story every different PARENT_NAME into ArrayList and execute items with the loop every time after i click on from_db.jsp?... link again and again to built a path of different PARENT_NAMES :

PARENT_NAME_1 / PARENT_NAME_2 / PARENT_NAME_3...

Or should i use some recursion function? I have no idea. Thanks

newj87a at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 6

I can't tell from your description whether recursion might be an option, here. What I've understood so far could be implemented like this:

<%

String[][] NAMES_N_PATHS = {

{"name1", "path1"},

{"name2", "path2"},

{"name3", "path3"},

// etc.

};

for (int i = 0;i < NAMES_N_PATHS.length;i++) {

out.println("<a href=\"" + response.encodeURL(NAMES_N_PATHS[i][1]) + "\">" + NAMES_N_PATHS[i][0] + "</a><br>");

}

%>

quittea at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 7
thank you quitte i'll try that
newj87a at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 8

hi guys again,let me explain my situatuin again, i have a code:

<code>

import java.io.*;

import java.net.*;

import java.util.*;

import javax.servlet.http.*;

import javax.servlet.ServletException;

public class FileWalk extends HttpServlet

{

public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

{

PrintWriter out = response.getWriter();

out.println("<a href=FileWalk?id=12>12</a>");

out.println("<a href=FileWalk?id=13>13</a>");

out.println("<a href=FileWalk?id=14>14</a>");

String str = request.getParameter("id");

ArrayList ar = new ArrayList();

ar.add(str);

Iterator it = ar.iterator();

while(it.hasNext()) {

String a = (String) it.next();

out.println(a);

}

}

}

</code>

if i press '12' , browser will display '12' , but if i pres '13' , i want browser to display '12' and '13' , and so on if i press '14' i would like to see '12','13','14' .... can you help me ? thank you

newj87a at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 9
Formatting tags are in square brackets, not standard html.. If you press the "code" button above the editor, you'll see an example
xiarcela at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 10

tanks , xiarcel :)

import java.io.*;

import java.net.*;

import java.util.*;

import javax.servlet.http.*;

import javax.servlet.ServletException;

public class FileWalk extends HttpServlet

{

public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

{

PrintWriter out = response.getWriter();

out.println("<a href=FileWalk?id=12>12</a>");

out.println("<a href=FileWalk?id=13>13</a>");

out.println("<a href=FileWalk?id=14>14</a>");

String str = request.getParameter("id");

ArrayList ar = new ArrayList();

ar.add(str);

Iterator it = ar.iterator();

while(it.hasNext()) {

String a = (String) it.next();

out.println(a);

}

}

}

if i press '12' , browser will display '12' , but if i pres '13' , i want browser to display '12' and '13' , and so on if i press '14' i would like to see '12','13','14' .... can you help me ? thank you

Message was edited by:

newj87

newj87a at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 11

Like this, you mean?out.println("<a href=FileWalk?id=12>12</a>");

out.println("<a href=FileWalk?id=13>12 and 13</a>");

out.println("<a href=FileWalk?id=14>12, 13, 14</a>");

DrClapa at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 12

as you see if you press '12' you get a string 'a' whitch is '12' , if you press '13' you get string '13'. I need if i press '12' i get '12' , when i press '13' and i would like to receive string '12' and also a new string '13', and if after that i press '14' i would like to see last two strings ('12','13') and also a new one - '14'

fist click:

out.println("12");

second :

out.println("12");

out.println("13");

third

out.println("12");

out.println("13");

out.println("14");

thanks

newj87a at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...
# 13
no suggestions?Message was edited by: newj87
newj87a at 2007-7-12 9:10:08 > top of Java-index,Java Essentials,Java Programming...